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

IN JAVA LANGUAGE PLEASE Write a complete program that generates the exact follow

ID: 3870220 • Letter: I

Question

IN JAVA LANGUAGE PLEASE

Write a complete program that generates the exact following output. In this program you need to prompt the user the number of hours, minutes and seconds and then output the equivalent amount in minutes and seconds and hours. Please refer to the shell provided for you for more details.

Requirements:

Must provide the exact same output word by word

Main method can only have two lines of code.

Proper indentation

Proper naming

Comments

Logic

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%
This program converts hours, minutes, second to second and display in on the screen. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%

How many times do you want to use the app? 2 What is your name? Alex Patten
Hi Alex Patten Lets start!!

Enter the number of the hours:3
Enter the number of the minutes: 5
Enter the number of the seconds: 360
3 Hours, 5 Minutes, and 360 Seconds is :

11460 seconds
191 Minutes 0 Seconds
3 Hours and 11 Minutes and 0 Seconds

What is your name? Mary Lee Hi Mary Lee Lets start!!

Enter the number of the hours:5
Enter the number of the minutes: 128
Enter the number of the seconds: 728
5 Hours, 128 Minutes, and 728 Seconds is :

26408 seconds
440 Minutes 8 Seconds
7 Hours and 20 Minutes and 8 Seconds

-----------------------------------------------------------------------------

THIS IS THE PSEUDOCODE:

Explanation / Answer

import java.io.*;
import java.util.*;

public class TimeShell {

    public static final int SEC_PER_MINUTE = 60;
    public static final int MIN_PER_HOUR = 60;

    public static void main(String[] args){
       
         Scanner kb = new Scanner(System.in);
         description();
         start(kb);
    }
    public static void start(Scanner sc){
       
         int hours = 0;
         int min = 0;
         int sec = 0;
         int hrsec = 0;
         int minsec = 0;
         int total = 0;

         System.out.print("How many times do you want to use the app? ");
         int n = Integer.parseInt(sc.nextLine());
         while (n > 0) {
            System.out.print("What is your name? ");
            String name = sc.nextLine();
            System.out.println("Hi "+ name + " Lets start!!");
            System.out.print("Enter the number of hours:");
            hours = sc.nextInt();
            System.out.print("Enter the number of minutes:");
            min = sc.nextInt();
            System.out.print("Enter the number of seconds:");
            sec = sc.nextInt();
            hrsec = hourToSec(hours);
            minsec = minToSec(min);
            total = hrsec + minsec + sec;
            System.out.println(hours + " Hours, " + min + " Minutes, and " + sec + " Seconds is:");
            System.out.println(total);
            minSec(total);
            hourMinSec(total);
            n--;
         }
        
      
    }
    public static void description(){
       System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ");
       System.out.println("%%% ");
       System.out.println("This program converts hours, minutes, second to second and display in on the screen. %%%%%% ");
       System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ");
      
    }
   public static void minSec(int totalSeconds)
   {
      int min = totalSeconds / SEC_PER_MINUTE;
      int sec = totalSeconds % SEC_PER_MINUTE;

      //output the result
      System.out.println(min +" Minutes " + sec + " Seconds");
   }
   public static void hourMinSec(int totalSeconds)
   {
      int hr = totalSeconds / (SEC_PER_MINUTE * 60);
      totalSeconds = totalSeconds % (SEC_PER_MINUTE * MIN_PER_HOUR);
      int min = totalSeconds / SEC_PER_MINUTE;
      int sec = totalSeconds % SEC_PER_MINUTE;
      System.out.println(hr + " Hours and " + min +" Minutes and " + sec + " seconds");
  
   }
   public static int minToSec(int min){
       return (min * SEC_PER_MINUTE);
   }
   public static int hourToSec(int hours){
       return (hours * MIN_PER_HOUR * SEC_PER_MINUTE );
   }

}