+ 1

How to make time converter program that is in module 1

3rd Jan 2021, 6:25 AM
Piyush Thakur
Piyush Thakur - avatar
5 Answers
0
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); int day = 12; int hours = 24; int minutes = 60; int seconds = 60; System.out.prinln(day*hours*minutes*seconds); //your code goes here } }
3rd Jan 2021, 6:30 AM
Piyush Thakur
Piyush Thakur - avatar
0
This is the code , I am stuck here I want to make time convertor
3rd Jan 2021, 6:31 AM
Piyush Thakur
Piyush Thakur - avatar
0
Piyush Thakur Why did you declared new variable day if we have days? You have to multiply with days not your own value.
3rd Jan 2021, 7:24 AM
A͢J
A͢J - avatar
0
Took me some time to figure it out. Kept bombing out on the #5 hidden test and I couldn't see why it was moaning. Eventually, I took a chance and it worked... go figure. Mine looked very much like yours except I changed the variable to a long as an int was too small a number. (and I only declared days once...). I also declared hours, minutes & seconds as long with their respective values initially... didn't pass the level 5 test though. This is (hopefully) the proper code as I am typing this from memory... import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); long days = scanner.nextLong(); long seconds = day * 24 * 60 *60; System.out.println(seconds); } }
2nd Mar 2021, 1:57 PM
David Silverwood
David Silverwood - avatar
- 1
Please share the code you have developed so far and indicate where you are stuck. We will be able to help you once we can see your code.
3rd Jan 2021, 6:28 AM
Elizabeth Kelly
Elizabeth Kelly - avatar