- 2

Java problem

You need a program to convert days to seconds. The given code takes the amount of days as input. Complete the code to convert it to seconds and output the result. Sample Input: 12 Sample Output: 1036800

1st Jun 2021, 1:01 PM
nawres
nawres - avatar
12 Answers
+ 3
12 days => 1036800sec 1 day = 24 hours 1 Hour = 60 mins 1 min = 60 seconds.. Now you can find correct solution I think...
1st Jun 2021, 1:18 PM
Jayakrishna 🇼🇳
+ 1
Where is your try.. ? Try it yourself first and post your attempt...
1st Jun 2021, 1:09 PM
Jayakrishna 🇼🇳
+ 1
12 days => 1036800sec 1 day = 24 hours 1 Hour = 60 mins 1 min = 60 seconds.. Now you can find correct solution I think...
1st Jun 2021, 1:23 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
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); //your code goes here int hours = 60; int mins=60; int res=days*hours*mins; System.out.println(res); }}
1st Jun 2021, 1:14 PM
nawres
nawres - avatar
0
I try but error still exists
1st Jun 2021, 1:15 PM
nawres
nawres - avatar
0
Hi! How many hours in one day?
1st Jun 2021, 1:19 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
24
1st Jun 2021, 1:20 PM
nawres
nawres - avatar
0
Use this in your formula
1st Jun 2021, 1:20 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
How?!!
1st Jun 2021, 1:22 PM
nawres
nawres - avatar
1st Jun 2021, 3:39 PM
Highman
Highman - avatar
0
Multiply days to minutes and minute's to seconds
2nd Jun 2021, 3:05 PM
Atharv Powalkar
0
And add all together!!
2nd Jun 2021, 3:06 PM
Atharv Powalkar