Write a java program tnat: prompts for and reads a 5-digit number representing a time in...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a java program tnat: prompts for and reads a 5-digit number representing a time in seconds calculates and outputs the corresponding hours, minutes and seconds using the same format as in the sample outputs below. - If the converted hours, minutes and seconds is a valid time (i.e., within the range 00:00:00 to 24:00:00) display the time as hh:mm:ss. Note: if the hours, minutes or seconds are equal to 0, you should display 00. If the converted time is not valid, swap the first and last digits of the original input and output the corresponding hours, minutes and seconds. Use 2 constant variables to store the number of minutes in an hour and the number of seconds in a minute. Following are 4 sample screenshots to illustrate the expected behavior of your program. Assume a perfect user who will always enter a positive integer with 5 digits. Note: Your program must display the same information and formatted the same. Welcome to Time Converter Program Please enter the seconds which will be converted: 86400 The correspond hours, minutes, seconds is 24 hrs, 0 mins, 0 secs. The valid time is: 24:00:00. Thank you for using the Time Converter Program! Write a java program tnat: prompts for and reads a 5-digit number representing a time in seconds calculates and outputs the corresponding hours, minutes and seconds using the same format as in the sample outputs below. - If the converted hours, minutes and seconds is a valid time (i.e., within the range 00:00:00 to 24:00:00) display the time as hh:mm:ss. Note: if the hours, minutes or seconds are equal to 0, you should display 00. If the converted time is not valid, swap the first and last digits of the original input and output the corresponding hours, minutes and seconds. Use 2 constant variables to store the number of minutes in an hour and the number of seconds in a minute. Following are 4 sample screenshots to illustrate the expected behavior of your program. Assume a perfect user who will always enter a positive integer with 5 digits. Note: Your program must display the same information and formatted the same. Welcome to Time Converter Program Please enter the seconds which will be converted: 86400 The correspond hours, minutes, seconds is 24 hrs, 0 mins, 0 secs. The valid time is: 24:00:00. Thank you for using the Time Converter Program!
Expert Answer:
Answer rating: 100% (QA)
Code for the given problem is as folllow import javautil public class Main public static voi... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these algorithms questions
-
Write a java program to compute all prime numbers less than equal to a given integer N using the algorithm "Sieve of Eratosthenes". The Sieve of Eratosthenes is a method used to compute all primes...
-
Write a Java program that simulates car racing, as shown in Figure 16.22(a). The car moves from left to right. When it hits the right end, it restarts from the left and continues the same process....
-
Write a Java program that displays a frame window 300 pixels wide and 200 pixels high with the title My First Frame. Place the frame so that its top left corner is at a position 50 pixels from the...
-
1. 3 2. MONEYBALL MOVIE WORKSHEET 1 1 1 11 6 7 1. Discuss the Oakland Athletics and what is going on with them? How are they look to change? What marketing techniques are being used to better the...
-
Divide the class into two or three teams. Each team should select a company whose product is being sold in a highly competitive marketplace. On the assumption that the product has not been selling...
-
Suppose you own the share of Estate Lancaster PLC and the expected dividends on this share is 0.17 in one year. Calculate the holding-period dollar gain and return on this share if its current price...
-
On June 15, 2010, Baileys Department Store purchased $4,300 of inventory on account from one of its suppliers. The terms were 3/15, n/45, FOB shipping point. On June 18 Baileys Department Store paid...
-
Foyert Corp. requires a minimum $ 30,000 cash balance. If necessary, loans are taken to meet this requirement at a cost of 1% interest per month (paid monthly). Any excess cash is used to repay loans...
-
Consider the following independent situations. Situation 1: Ducharme Corporation purchased electrical equipment at a cost of $62,000 on June 2, 2017. From 2017 through 2020, the equipment was...
-
Examine the loan amortization table for a $210,000, 15 year mortgage with an APR of 6%. The borrower paid an extra $100 each month towards the principal. Determine the missing amounts. Payment...
-
What is the importance of Ratio Analysis in Liquidity Ratios? What is Acid-test Ratio, what is it used for? What is Return on Assets (ROA) and what is it used for?
-
Powerhouse Ltd purchased machinery on 2 January 2019, at a cost of $800 000. The machinery is depreciated using the straightline method over a useful life of 8 years with a residual value of $80 000....
-
How does a side-by-side bar chart present data better than a contingencies table?
-
The winners in an Olympic race are decided according to the recorded time up to the hundredth decimal point. a. Explain why the recorded time is a continuous numerical variable. b. Explain why the...
-
A hotel offers comfort, deluxe, and luxury rooms. Explain why the type of hotel rooms is an example of an ordinal scaled variable.
-
How is a Pareto chart a better representation of data in comparison to a pie chart?
-
Calculate the following for a 3 ft 4 ft window with the label to the right. The summer design conditions for peak cooling load are 70 and 60% RH inside; 90 and 90% outside; and a peak direct solar...
-
A report from the college dean indicates that for the previous semester, the grade distribution for the Department of Psychology included 135 As, 158 Bs, 140 Cs, 94 Ds, and 53 Fs. Determine what kind...
-
Create a new class named MyGraph as a subclass of UnweightedGraph that contains a method for finding all connected components in a graph with the following header:public?List>...
-
Write a program that reads a connected graph from a file. The graph is stored in a file using the same format specified in Exercise. Your program should prompt the user to enter the name of the file,...
-
Write a program that compresses a source file into a target file using the Huffman coding method. First use ObjectOutputStream to output the Huffman codes into the target file, and then use...
-
The personal income per capita of a state is the total income of all adults in the state, divided by the number of adults. The following table presents the personal income per capita (in thousands of...
-
The following table presents the weekly attendance, in thousands, at Broadway shows during a recent season. a. Find the mean and median weekly attendance. b. Based on the mean and median, would you...
-
A sample of 32 U.S. adults was surveyed and asked, Do you get most of your information about current events from newspapers, magazines, the Internet, television, radio, or some other source? The...
Study smarter with the SolutionInn App