- 1
Can anyone help me with my Test Code? (Java)
The test expects from the to convert Days into Seconds. 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 = 288; int min = 17280; int sec = 1036800; System.out.println(172800); //your code goes here } } This is my current code. But Test Case 2 expects the output 4579200 and i have no idea how to continue..
1 ответ
+ 3
You need to know how to convert everything to seconds?
here's how it goes ..
1 day=24 hours
>= x days = x*24 hours
1hour = 60 mins
=> x*24 hours = x*24*60 mins
1 min = 60 seconds
=> x*24*60 mins = x*24*60*60 seconds
now with that in mind the code would look like this
import java.util.Scanner;
public class Program {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int days = scanner.nextInt();
System.out.println(days*24*60*60);
}
}