0
What is wrong with my code? It's not working
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); int days = 24 hours; int hour = 60 min; int min = 60 seconds; int result = days*hour*min; System.out.println(result); } }
3 ответов
+ 11
int hour = 24 ;
int min = 60 ;
int sec = 60 ;
int result = days*hour*min*sec;
+ 2
Look at your variables, for integer variable value must be integer only
Ex: int days = 24;
+ 2
Just found a way out
Thanks a lot!
I did it this way
import java.util.Scanner;
public class Program {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int days = scanner.nextInt();
int time = days*24*60*60;
System.out.println(time);
}
}