- 1
My calculator prog...not runing.. Please help me...
java
6 odpowiedzi
+ 15
How could anyone in the world help you? You didn't provide any minimal or useful information.
+ 5
At first, you must write for scanner in line 8 as :
Scanner sc = new Scanner(System.in);
you use in code scanner as sc, but in assign you named it scanner
+ 1
Your code works for me, I don't see any error
+ 1
sourabh mahat from now, try to specify the language in revelant tags, and to input the link of the code (press "insert" then "insert code" then select "my codes" and select the code you want and then press done) and to explain the problem in description.
0
import java.util.Scanner ;
class MyClass
{
public static void main(String[ ] args)
{
Scanner scanner =new Scanner (system.in);
int a,b,c,A;
{
System.out.println("enter your choice");
System.out.println("1st for add");
System.out.println("2nd for sub");
System.out.println("3rd for multi");
System.out.println("4th for divide");
System.out.println("5th for exit");
A=sc.nextInt();
switch (A){
case 1 :
System.out.println ("enter any two intger");
a=sc.nextInt();
b=sc.nextInt();
c=a+b;
System.out.println(c);
break ;
case 2:
System.out.println ("enter any two intger");
a=sc.nextInt();
b=sc.nextInt();
c=a-b;
System.out.println(c);
break ;
case 3:
System.out.println ("enter any two intger");
a=sc.nextInt();
b=sc.nextInt();
c=a*b;
System.out.println(c);
break ;
case 4:
System.out.println ("enter any two intger");
a=sc.nextInt();
b=sc.nextInt();
c=a/b;
System.out.println(c);
break;
}
}}
}
0
can anybody correct this error