+ 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); } }
9 Answers
+ 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 ;)
+ 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);
}
}
+ 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);
+ 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 .
+ 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);
}
}
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);
}
}
0
Hi. I try all this codes but it did not work.
How I can go to second task?
- 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 đźđł
- 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); } }