+ 5

I don't understand where have I mistaken in the program. I would appreciate any help.

Program : import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner input = new Scanner (System .in); int a,b,c,ch; System .out .println ("Enter the two numbers\n"); a = input.nextInt(); b = input.nextInt(); System .out.println ("Enter the operation to perform\n1.Addition\n2.Subtraction\n3.Multiplication\n4.Division\n"); ch=input.nextInt(); switch (ch) { case 1: c=a+b; System .out.println ("Addition of the two numbers is"+c); break; case 2: c=a-b; System .out.println ("Subtraction of the two numbers is"+c); break; case 3: c=a*b; System .out.println ("Multiplication of the two numbers is"+c); break; case 4: c=a/b; System .out.println ("Division of the two numbers is"+c); break; default: System .out.println ("Maybe you have entered a wrong choice\nSorry, but we can't process you request\n"); } System .out.println ("Thank you for watching my program. Hope you liked it! "); } }

2nd Aug 2016, 12:21 PM
Sanmay
Sanmay - avatar
6 Answers
+ 7
The playground has issues with white spaces for some reason. Causes an error when normally it shouldn't. Can go through and remove all your extra spaces between words and parenthesis, and words and periods.
2nd Aug 2016, 12:55 PM
James
James - avatar
+ 2
Thanks a lot. It worked!
2nd Aug 2016, 1:07 PM
Sanmay
Sanmay - avatar
0
Are you trying this in an ide or code playground?
2nd Aug 2016, 12:29 PM
James
James - avatar
0
I wrote it in the in-app provided playground.
2nd Aug 2016, 12:49 PM
Sanmay
Sanmay - avatar
0
it's too work
2nd Aug 2016, 2:51 PM
parteek
parteek - avatar
0
Anyone know another code playground i can download in my phone.?
31st Jan 2017, 12:31 AM
Breith Aparicio
Breith Aparicio - avatar