0

Help !!! I have to write a code that calculates 2 days in seconds.

import java.util.*; import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); int hours= days * 24; int minutes = days *24*60; int seconds = days*24*60*60; //введите код сюда system.out.println(2*days*minutes*seconds); } }

19th May 2022, 6:35 AM
Sarvar Khidirov
Sarvar Khidirov - avatar
7 Réponses
0
I know but my code doesn’t work
19th May 2022, 6:45 AM
Sarvar Khidirov
Sarvar Khidirov - avatar
0
Java is case-sensitive. So, you cannot write 'system', but 'System'. Also, result is incorrect, since you're doing some unnecessary multiplication. Your answer is stored in variable 'seconds' (it's just a simple arithmetic, check it on your own). So, considering all of these, your code will look like: import java.util.*; import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); int hours= days * 24; int minutes = days * 24 * 60; int seconds = days * 24 * 60 * 60; System.out.println(seconds); } }
19th May 2022, 7:03 AM
Alexus100
Alexus100 - avatar
0
Alexus100 thanks
19th May 2022, 5:07 PM
Sarvar Khidirov
Sarvar Khidirov - avatar