+ 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");
6 Respuestas
+ 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...
+ 1
Without quotes on everything but "Hello" I get an illegal start of line error.
+ 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);
+ 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
+ 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
+ 1
this is not javascript...