Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a program that asks the user to enter a number of seconds, and works as f

ID: 3528303 • Letter: D

Question

Design a program that asks the user to enter a number of seconds, and works as follows: ? 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 number 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 greater 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");



}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote