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
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 MY CODE AND WHAT I HAVE SO FAR PLEASE CORRECT
import java.util.Scanner; public class TimeShell { //declare all your constants public static final int SEC_PER_MINUTE = 60; public static final int SEC_PER_HOUR = 3600; public static void main(String[] args) { Scanner kb = new Scanner(System.in); description(); start(kb); //minSec(800); //hourMinSec(1); } public static void start(Scanner kb) { int hrs, min, sec, totalSeconds; System.out.print("How many times do you want to use the app?"); for (int i = 1; i <=3; i++) { int times = kb.nextInt(); kb.nextLine(); System.out.print("What is your name? "); String name = kb.nextLine(); System.out.println("Hi "+ name + " lets start!!"); System.out.println(); System.out.print("Enter the number of the hours: "); int hours = kb.nextInt(); kb.nextLine(); System.out.print("Enter the number of the minutes: "); int minutes = kb.nextInt(); kb.nextLine(); System.out.print("Enter the number of the seconds: "); int seconds = kb.nextInt(); kb.nextLine(); System.out.println(hours +" Hours, " + minutes +" Minutes, and " + seconds + " Seconds is :"); System.out.println(); System.out.println("11460 seconds"); minSec(minutes); hourMinSec(seconds); hourToSec(hours); minToSec(seconds); } } public static void totalSeconds() { } public static void minSec(int totalSeconds) { int min = totalSeconds / SEC_PER_MINUTE; int sec = totalSeconds % SEC_PER_MINUTE; //output the result System.out.println(totalSeconds + " seconds is " + min +" minutes and " + sec + " seconds"); } /*This method get the total number of the seconds and calculates the number of hours, minutes and second, then outputs the result*/ public static void hourMinSec(int totalSeconds) { int hour; int min; int sec; int secLeft; hour = totalSeconds / 3600; secLeft = totalSeconds % 3600; min = secLeft / 60; sec = secLeft % 60; System.out.println("3 Hours and 11 Minutes and 0 Seconds"); } /*calulates the number of the seconds in the given hours and returns the value*/ public static int hourToSec(int hours) { int sec = hours * SEC_PER_HOUR; return sec; } /*This method calculates the number of the seconds in the given number of minutes*/ public static int minToSec(int min) { return (min *SEC_PER_MINUTE); } /*outputs the description of the program*/ 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("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started