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

Write a program that ask the user to enter a number of seconds. There are 60 sec

ID: 3638654 • Letter: W

Question

Write a program that ask the user to enter a number of seconds. 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 3600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3600, the program should display the number of hours in that many seconds.There are 86400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86400, the program should display the number of days in that many seconds.

Explanation / Answer

please rate - thanks

in JAVA

import java.util.*;
public class main
{
public static void main(String [] args)
{ int seconds,minutes=0,hours=0,days=0;
Scanner in=new Scanner(System.in);
System.out.print("enter a number of seconds: ");
seconds=in.nextInt();
System.out.println(seconds+" seconds is:");
if(seconds>86400)
    {days=seconds/86400;
    seconds%=86400;
    System.out.println(days+" days");
    }
if(seconds>3600)
    {hours=seconds/3600;
    seconds%=3600;
    System.out.println(hours+" hours");
    }
if(seconds>60)   
   {minutes=seconds/60;
    seconds%=60;
    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