كود:
boolean run = true ;
while (run) {
System.out.println("Calculator Program");
System.out.println("=============================================");
System.out.println("1. For additon of two numbers"+"\t"+"Press 1");
System.out.println("2. For additon of two numbers"+"\t"+"Press 2");
System.out.println("3. For additon of two numbers"+"\t"+"Press 3");
System.out.println("4. For additon of two numbers"+"\t"+"Press 4");
System.out.println("5. For additon of two numbers"+"\t"+"Press 5");
System.out.println("6. For additon of two numbers"+"\t"+"Press 0");
System.out.println("=============================================");
Scanner i = new Scanner (System.in);
System.out.print("Enter Your choice: ");
int x = i.nextInt();
if (x==1)
System.out.println("Calculator Program - addition of two numbers");
else if (x==2)
System.out.println("Calculator Program - addition of two numbers");
else if (x==3)
System.out.println("Calculator Program - addition of two numbers");
else if (x==4)
System.out.println("Calculator Program - addition of two numbers");
else if (x==5)
System.out.println("Calculator Program - addition of two numbers");
else {
}
System.out.println("=============================================");
System.out.print("Enter the first number: ");
double n1 = i.nextInt();
System.out.print("Enter the second number: ");
double n2 = i.nextInt();
double n3 ;
if (x==1){
n3 = n2+n1;
System.out.println("additon of "+n1+" and "+n2+" is "+n3);
}
else if (x==2){
n3 = n2-n1;
System.out.println("additon of "+n1+" and "+n2+" is "+n3);
}
else if (x==3){
n3 = n2*n1;
System.out.println("additon of "+n1+" and "+n2+" is "+n3);
}
else if (x==4){
n3 = n2/n1;
System.out.println("additon of "+n1+" and "+n2+" is "+n3);
}
else if (x==5){
n3 = n2%n1;
System.out.println("additon of "+n1+" and "+n2+" is "+n3);
}
else {
}
System.out.println("Do you want to continue ? ");
System.out.println("Press 1 to continue");
System.out.println("Press 0 to finish the program");
System.out.println("=============================================");
System.out.print("Enter Your choice: ");
int y = i.nextInt();
if (y==1)
run = true ;
else if (y==0)
run = false ;
سويتو ع السريع واوامر سهله بدون مثود او مصفوفات ويوجد بعض الاخطاء الاملائية للطباعة للوقت ههههه :) بالتوفيق