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); } }
7 odpowiedzi
0
I know but my code doesn’t work
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);
}
}
0
Alexus100 thanks