1. Calculator using switch case: import java.util.Scanner; public class Calculator{ public static void main (String[] args) { Scanner scanner = new Scanner(System. in ); System. out .println( "Calculator" ); System. out .println( "1. Addition" ); System. out .println( "2. Subtraction" ); System. out .println( "3. Multiplication" ); System. out .println( "4. Division" ); System. out .println( "5. Exit" ); System. out .println( "Enter your choice: " ); int choice = scanner.nextInt(); switch (choice){ case 1 : System. out .println( "Enter two numbers: " ); int num1 = scanner.nextInt(); int num2 = scanner.nextInt(); int sum = num1 + num2; System. out .println( "The sum is: " + sum); break ; case 2 : ...
5a1 import 'package:flutter/material.dart' ; class MyStatelessWidget extends StatelessWidget { @override Widget build ( BuildContext context) { return Scaffold ( appBar : AppBar ( title : Text ( 'Stateless Widget Example' ), ), body : Center ( child : Text ( 'Hello, Flutter!' , // In this example, MyStatelessWidget does not change after it is built. The text "Hello, Flutter!" is static. style : TextStyle (fontSize : 24 ), ), ), ); } } void main () { runApp ( MaterialApp ( home : MyStatelessWidget (), )); } 5a2 import 'package:flutter/material.dart' ; class MyStatefulWidget extends StatefulWidget { @ override _MyStatefulWidgetState createState...
Comments
Post a Comment