Question: Please draw a flowchart Challenge: The Time calculator Coding challenge - There are 60 seconds in a minute. If the number of seconds entered by
Please draw a flowchart
Challenge: The Time calculator Coding challenge
- 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 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 hours in that many seconds.
Here's my code:
import java.util.Scanner;
public class TimeCalculator {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number of seconds: ");
int sec = sc.nextInt();
if(sec>=60&& sec
System.out.println(sec/60 + " minutes and " + sec%60 + " sec");
else if (sec>=3600&& sec
int minutes = sec/60;
int hours = minutes/60;
System.out.println(hours + " hours and " + minutes%60 + " minutes " + sec%60 + " seconds");
}else if(sec
System.out.println(sec +" seconds");
else{
int minutes = sec/60;
int hours = minutes/60;
int day = hours/24;
System.out.println(day + " day and " + hours%24 + " hours and " + minutes%60 + " minutes " + sec%60 + " seconds");
}
}
} ========================= See Output 
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
