create a menu driven application to perform addition,subtraction,multiplicaltion and devision of two numbers.
//create a menu driven application to perform addition,subtraction,multiplicaltion and devision of two numbers.
import java.util.Scanner;
class calculator
{
public static void main(String[] arg)
{
Scanner sc=new Scanner(System.in);
char c1;
do{
System.out.print("Enter two number :");
int a=sc.nextInt();
int b=sc.nextInt();
System.out.println("\t\t----calculator choice Menu----\n");
System.out.println("\t\t\t 1 Addition");
System.out.println("\t\t\t 2 Subtraction");
System.out.println("\t\t\t 3 Multiplication");
System.out.println("\t\t\t 4 Division");
System.out.println("\n\t\t\t Enter choice : ");
int ch=sc.nextInt();
switch(ch)
{
case 1:
int s=a+b;
System.out.println("Addition = "+s);
break;
case 2:
int s1=a-b;
System.out.println("Subtraction = "+s1);
break;
case 3:
int s2=a*b;
System.out.println("Multiplication = "+s2);
break;
case 4:
int s3=a/b;
System.out.println("Division = "+s3);
break;
default:
System.out.println("invalid choice");
break;
}
System.out.println("DO YOU WANT TO CONTINUE PLZ PRESS (y/n)");
c1=sc.next().charAt(0);
}while(c1=='y' || c1=='Y');
}
}
Comments
Post a Comment