+ 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);} } }

15th Dec 2017, 6:25 PM
Clarke
Clarke  - avatar
6 Answers
+ 13
Fixed, please see the comments. Input format should be like: 26.5 a 17 https://code.sololearn.com/cSgm45t7MpPr/?ref=app
15th Dec 2017, 6:33 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 3
a is a variable name, you need to put quotations before and after the a
15th Dec 2017, 6:30 PM
Joshua
Joshua - avatar
+ 3
Thanks guys šŸ˜Š
15th Dec 2017, 7:18 PM
Clarke
Clarke  - avatar
+ 2
Thank you everyone I figured it out šŸ™‚
15th Dec 2017, 7:38 PM
Clarke
Clarke  - avatar
+ 2
Check out your help applied I made a public code called Calculator
15th Dec 2017, 7:46 PM
Clarke
Clarke  - avatar
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.
15th Dec 2017, 7:21 PM
H Chiang