how to do the Time converter in Java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 7

how to do the Time converter in Java

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days; int hours = 60; int mins=60; //help me fix this System.out.println("Results : "); days=scanner.nextInt(); System.out.println(""+(days*24*hours*mins)); } }

14th Jan 2021, 5:37 AM
Michael John Lano
Michael John Lano - avatar
33 Answers
+ 40
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int hours = 24, minutes = 60, seconds = 60; int days = scanner.nextInt(); System.out.println(days * hours * minutes * seconds); } }
25th Jun 2021, 9:34 PM
Jorge Garzón
Jorge Garzón - avatar
+ 9
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); //your code goes here System.out.println (days*24*60*60); } }
14th Jan 2021, 5:51 AM
Atul [Inactive]
+ 4
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); //your code goes here int days = scanner.nextInt(); int hours = days * 24; int minutes = hours * 60; int seconds = minutes * 60; System.out.println(seconds); } }
22nd Aug 2021, 3:20 AM
GUNTUR MELLINIAWAN
GUNTUR MELLINIAWAN - avatar
+ 3
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 = 24; int minutes = 60; int seconds = 60; int result = days * hours * minutes * seconds; System.out.println(result); } }
3rd Aug 2021, 11:53 AM
Viviane Ehwein
Viviane Ehwein - avatar
+ 2
Michael John Lano Its failing because you are using the println function instead of just print. The ln creates an extra line that the solution check doesn’t like. Use: System.out.print(days*24*60*60);
14th Jan 2021, 5:54 AM
Elizabeth Kelly
Elizabeth Kelly - avatar
+ 1
mport java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days=24; int hours = 60; int mins=60; int res=days*hours*mins; System.out.println(res); }} //simple.
15th May 2021, 6:49 AM
Dhanush Ravish
Dhanush Ravish - avatar
+ 1
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 minute = hours*60; int seconds = minute*60; System.out.println (seconds); } }
1st Jul 2021, 6:02 AM
DEPURU GNANENDRA
DEPURU GNANENDRA - avatar
+ 1
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 min = hours * 60; int sec = min * 60; System.out.print(sec); //you should use print instead of printIn } }
11th Jul 2021, 8:38 PM
ibrahim adamou
ibrahim adamou - avatar
0
Days*24*60*60
14th Jan 2021, 5:51 AM
Atul [Inactive]
0
I cannot get it right either
28th May 2021, 12:24 AM
Nicole Anderson
Nicole Anderson - avatar
0
This is real full 1000% working code try this and follow me please. import java.util.Scanner; public class DayToSecondsConversion { public static void main(String[] args) { long days; Scanner in = new Scanner(System.in); days = in.nextLong(); long seconds = days * 24 * 60 * 60; System.out.println(seconds); } }
15th Jun 2021, 2:46 AM
Het Vyas
Het Vyas - 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(); //your code goes here System.out.println(days*24*60*60); } }
29th Jun 2021, 5:17 PM
Fatin Nazihah
Fatin Nazihah - avatar
0
Thanks
7th Jul 2021, 12:42 AM
Faro
Faro - avatar
0
this is the correct answer import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int hours = 24, minutes = 60, seconds = 60; int days = scanner.nextInt(); System.out.println(days * hours * minutes * seconds); } } if this code didn't work please call me on this number 9345563944
19th Nov 2021, 1:10 PM
SANKARA NAARAYANAN
0
No logro hacer Que me imprima los 3 resultados a la vez y no me deja pasar , me los imprime siempre en el primer Test , como soluciono eso I can not make him print the 3 results at the same time and he does not let me pass, he always prints them in the first test, how do I solve that
30th Nov 2021, 3:21 PM
Cesar Rivas
0
int day = days*24*60*60; System.out.println(day);
15th Jan 2022, 10:08 PM
Kheye
Kheye - 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(); //your code goes here System.out.println(days*24*60*60); } }
20th Jan 2022, 10:32 AM
Shourya Chourasia
Shourya Chourasia - avatar
0
If anyone is looking for the right answer here, scroll to the comment by Viviane Ehwein. I tried every possible combination with different formats and subtle tweaks, but that is the one that works. Thank you.
26th Jan 2022, 12:25 AM
Gabrielle Holt
Gabrielle Holt - avatar
0
I came back to add that this works too. You don't need to include an extra line of int results since you can place the equation directly in the output line. Play around with the format a bit, there seems to be at least a couple of different acceptable answers that achieve the same answer. import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); //your code goes here int hours = 24; int minutes = 60; int seconds = 60; System.out.println(days * hours * minutes * seconds); } }
26th Jan 2022, 12:40 AM
Gabrielle Holt
Gabrielle Holt - avatar
0
Still not working have tried it
24th Feb 2022, 3:04 PM
winnie wasega
winnie wasega - avatar