+ 2
Can someone help please?
This is my code: It says that the a is not recognised-try it Can someone correct my code pleaseš¶ Thank you import java.util.Scanner; public class Program { public static void main(String[] args) Scanner AA = new Scanner(System.in); double AAA = AA.nextDouble(); String BBB = AA.nextLine(); BBB = AA.nextLine(); double CCC = AA.nextDouble(); switch (BBB){ case a: double DDD = AAA + CCC; System.out.println("Result= " + DDD);} } }
6 Answers
+ 13
Fixed, please see the comments. Input format should be like:
26.5
a
17
https://code.sololearn.com/cSgm45t7MpPr/?ref=app
+ 3
a is a variable name, you need to put quotations before and after the a
+ 3
Thanks guys š
+ 2
Thank you everyone I figured it out š
+ 2
Check out your help applied
I made a public code called Calculator
0
Shamina is correct but you also need to know how you want/expect the input to be.
Before it was expecting:
# string
string
#
Now it is expecting:
#
string
#
Also it was trying to see what the variable āaā was.
To troubleshoot, I inserted print statements after each iteration assignment to see what it was seeing.
Without any prompt, the user needs to read the code to determine input.
Also why separate the trigger?
E.g. why
#
String
#
And not
#
#
String
Or vice versa
Also you had mismatched {}, so that is why comments are recommended for beginners.