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

16th Jun 2021, 1:32 AM
Мирбек Исмаилов
Мирбек Исмаилов - avatar
3 Answers
+ 11
int hour = 24 ; int min = 60 ; int sec = 60 ; int result = days*hour*min*sec;
16th Jun 2021, 1:34 AM
Simba
Simba - avatar
+ 2
Look at your variables, for integer variable value must be integer only Ex: int days = 24;
16th Jun 2021, 1:35 AM
Akshay Harshora
Akshay Harshora - avatar
+ 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); } }
16th Jun 2021, 1:37 AM
Мирбек Исмаилов
Мирбек Исмаилов - avatar