+ 1

Convert days into seconds Java Project

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); int hour = 24 * days; int min = hour * 60; int sec = min * 60; System.out.println(sec); } }

9th Mar 2021, 4:57 PM
Shankavi Thiruchchelvarajan
9 Réponses
+ 2
you must output number of seconds in 'days' days, but you are outputing number of seconds in only one day... you should multiply 'sec' by 'days' to get correct result ;)
9th Mar 2021, 6:38 PM
visph
visph - avatar
+ 2
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); /* 1 day = 24hours 1 hour = 60minutes 1 minute = 60seconds*/ System.out.println("TIME CONVERTER"); System.out.println("Please enter your number of days"); int Days = days.nextInt(); int hours = 24 * Days; System.out.prinln("Your hours are .."+hours); int minutes = 60 * hours; System.uot.prinln("Your minutes are..."+minutes); int seconds = 60 * minutes; System.out.prinrln("Your days converted into seconds is: "+seconds); } }
16th Jul 2021, 6:51 AM
Benjamin Adom
Benjamin Adom - avatar
+ 2
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); int sec= days *24*60*60; System.out.println(sec);
28th Mar 2022, 4:45 AM
Michael Mirhom
+ 1
import java.util.Scanner; public class DaysSeconds { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Write a value "); int days = Integer.valueOf(scanner.nextLine()); int sec = 86400 * days; System.out.println(sec); } } Since we are asking days as input I dont think there is need for extra min and sec lines .
10th Sep 2021, 10:23 AM
Pranay Mokida
Pranay Mokida - avatar
+ 1
import java.util.Scanner; public class DaysSeconds { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = Integer.valueOf(scanner.nextLine()); int sec = 86400 * days; System.out.println(sec); } }
15th Jul 2022, 10:08 PM
Shams Raza
Shams Raza - avatar
0
import java.util.Scanner; public class Program { public static void main(String[] args) { int Days, Seconds; Scanner s = new Scanner(System.in); System.out.print("Enter the Number of Days: "); Days = s.nextInt(); Seconds = Days*86400; System.out.println("\nTotal Seconds = " +Seconds); } }
14th Dec 2021, 7:46 PM
Tsegabrehan Zerihun Habtemariam
Tsegabrehan Zerihun Habtemariam - avatar
0
Hi. I try all this codes but it did not work. How I can go to second task?
30th Dec 2022, 12:21 PM
Milena Szczubełek
Milena Szczubełek - avatar
- 1
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); long days = scanner.nextInt(); days = days*24*60*60; System.out.println(days); //your code goes here } } My code is running well check using this 🇮🇳
30th Jul 2022, 8:37 AM
Omprakash
Omprakash - avatar
- 2
Project import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); int hour = 24 * days; int min = hour * 60; int sec = min * 60; System.out.println(sec); } }
25th Jun 2021, 9:23 AM
DHANANJAY BOTHIKAR