+ 1

Please help me figure out why this won't display when I run the code. It's on JavaScript.

Can't figure out why this won't display what it's supposed to please help Scanner input = new Scanner(System.in); String yourname = input.next(); int num1 = input.nextInt(); int num2 = input.nextInt(); int result = num1*num2; System.out.println("Hello" + "yourname" + "num1" * "num2" = "result");

5th Mar 2020, 3:55 PM
Timothy Buhlig
6 Réponses
+ 2
You yourname as variable but if put that in " ", it becomes string not variable... You can see this by observing output... For others apply same... Edit: System.out.println("Hello " +yourname+ " " +num1+ " *." +num2+ " =" +result); By the way, this is Java code not from JavaScript...
5th Mar 2020, 4:00 PM
Jayakrishna 🇮🇳
+ 1
Without quotes on everything but "Hello" I get an illegal start of line error.
5th Mar 2020, 4:35 PM
Timothy Buhlig
+ 1
The code snippet you write is in java not JavaScript code.. In JavaScript, you have use prompt and console.write methods... Ex: var yourname=promt("enter yourname"); Console.Write(yourname);
5th Mar 2020, 6:09 PM
Jayakrishna 🇮🇳
+ 1
Ok if I'm writing it in Java what is the problem with it? Sorry to be a pain I just can't figure it out
5th Mar 2020, 6:18 PM
Timothy Buhlig
+ 1
I given explanation in my fisrt post.. And added correct way also.. Additionally for that you need to import util package... If you still any trouble, then save code and share code link, then Im able to what else you need?.. Hope this clears... Edit: From this example you can see... Timothy Buhlig (updated to your code) https://code.sololearn.com/cmD7K5JJ1Rg4/?ref=app
5th Mar 2020, 6:24 PM
Jayakrishna 🇮🇳
+ 1
this is not javascript...
5th Mar 2020, 11:44 PM
Ahmed Samy
Ahmed Samy - avatar