There are 60 seconds in a minute. If the number of seconds entered by the user i
ID: 3620641 • Letter: T
Question
There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds.There are 3,600 seconds in an hour. if the member of seconds entered by the user is greater than or equal to 3,600,the program should display the number of hours in that many seconds.
There are 86,400 seconds in a day. If the number of seconds entered by the user is grater than or equal to 86,400, the program should display the number of days in that many seconds.
Explanation / Answer
please rate - thanks
not sure what you want
I think it's the first
import java.util.*;
public class main2
{public static void main(String[] args)
{Scanner in=new Scanner(System.in);
int seconds,hours, minutes, days;
System.out.print("Enter number of seconds? ");
seconds=in.nextInt();
System.out.print(seconds+" seconds is: ");
if(seconds>=86400)
System.out.println(seconds/86400+" days");
else if(seconds>=3600)
System.out.println(seconds/3600+" hours");
else if(seconds>60)
System.out.println(seconds/60+" minutes");
}
}
------------------------------------
or
import java.util.*;
public class main
{public static void main(String[] args)
{Scanner in=new Scanner(System.in);
int seconds,hours, minutes, days;
System.out.println("Enter number of seconds? ");
seconds=in.nextInt();
System.out.println(seconds+" seconds is: ");
days=seconds/86400;
seconds%=86400;
hours=seconds/3600;
seconds%=3600;
minutes=seconds/60;
seconds%=60;
System.out.println(days+"days");
System.out.println(hours+"hours");
System.out.println(minutes+"minutes");
System.out.println(seconds+"seconds");
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.