Fix the Error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Fix the Error

i created that java program to do some basic bank work.that user enter his id number trial then a message show on screen that choice the option the user enter his choice and voila it should work. but unfortunately it causes error(bad operands type +,- etc). kindly fix it. https://code.sololearn.com/c2O41bpue73g/#java

31st Jul 2019, 3:51 PM
Haris Khan
Haris Khan - avatar
1 Answer
+ 1
rewrite it with use only one Scanner like: Scanner sc = new Scanner(System.in); int a = sc.nextInt(); String str = sc.next(); Double d = sc.nextDouble(); don't use var as variable name it is reserved keyword (Java 10) var1 = sc.next().toUpperCase(); //get only upper case letters ... } while(! var1.equals("E") ); //it is necessary compare Strings with .equals() because it has more input, on SL you can debug test it like: Scanner sc = new Scanner("100 200 C 300 D 400 S E"); //System.in);
31st Jul 2019, 4:54 PM
zemiak