0

What am I doing wrong

You need a program to convert days to seconds. This code uses the number of days as input. Complete the code to convert the number of days to seconds and print the result. Input example: 12 Result example: 1036800 import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); int a = sc.nextInt(); int b = (a*24*60*60); System.out.println(b); } }

18th Aug 2022, 11:59 AM
Akridem
Akridem - avatar
3 ответов
+ 4
int b = (days * 24 * 60 * 60);
18th Aug 2022, 12:07 PM
IOS DEV
IOS DEV - avatar
+ 2
Why are you reading and calculating <a> when you have already read <days>? What if the test provide you only one input at runtime? what becomes of <a>? Basically, you get wrong result cause you're supposed to calculate using <days> instead of <a>
18th Aug 2022, 12:07 PM
Ipang
+ 2
Thanks you so much!!
18th Aug 2022, 12:13 PM
Akridem
Akridem - avatar