+ 1
Why i have this error
I am trying to make a program in java that passes the days that you enter to seconds but I don't know why it gives me an error. Code: import java.util.Scanner; class MyClass { public static void main(String[ ] args) { Scanner myVar = new Scanner(System.in); myvar2 = myvar *24; myvar2 = myvar2 * 60; System.out.println(myVar.nextLine()); } }
2 Answers
+ 2
myvar and myVar are diferent nsmes, there is typo
how to read number:
int myvar2 = myVar.nextInt();
how to print number
System.out.println( myvar2 );
+ 2
Save code in playground and share link here.. That's not readable code.. Looks weird..
Anyways, as you declared, myVar is an object of Scanner class, not a normal integer variable. So those two multiplications are invalid, errors.
What are trying actually..?
you never used those two for any output.. myvar2 is undeclared still.
comment those two lines.. it's works fine for taking a line of input and print in screen.