Program to Develop a Menu Driven Calculator In BlueJ #BlueJ #JAVA, #ComputerProgramming #Programming

preview_player
Показать описание
Program to Develop a Menu Driven Calculator In BlueJ
#BlueJ, #JAVA, #ComputerProgramming, #Programming
Рекомендации по теме
Комментарии
Автор

At result = a+b is showing expected error

কবিতায়রীতা
Автор

Bro you could do it easily by switch case

ranjitdas
Автор

there is no need to include a and b in the if statement they can be taken input along with the print statements above .
import java.util.*;
public class calculator2
{
public static void main()
{
int a, b, result, ch;
Scanner SC = new Scanner(System.in);

System.out.println("Menu Selection");
System.out.println("Press 1 for Addition");
System.out.println("Press 2 for Difference");
System.out.println("Press 3 for Multiplication");
System.out.println("Press 4 for Division");
System.out.println("Please Enter Your Choice : ");
ch = SC.nextInt();
System.out.println("Enter the 1st Number :");
a = SC.nextInt();
System.out.println("Enter the 2nd Number :");
b = SC.nextInt();
if(ch==1)
{
result=a+b;
System.out.println("Result is :"+result);
}
else if(ch==2)
{
result=a-b;
System.out.println("Result is :"+result);
}
else if(ch==3)
{
result=a*b;
System.out.println("Result is :"+result);
}
else if(ch==4)
{
result=a/b;
System.out.println("Result is :"+result);

}



}



}

arc.
join shbcf.ru