Write a program to calculate the number of seconds since midnight. For example, suppose the time...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program to calculate the number of seconds since midnight. For example, suppose the time is 1:02:05 AM. Since there are 3600 seconds per hour and 60 seconds per minutes, it has been 3725 seconds since midnight (3600 * 1 + 2 * 60 + 5 = 3725). The program asks the user to enter 4 pieces of information: hour, minute, second, and AM/PM. The program will calculate and display the number of seconds since midnight. [Hint: be very careful when the hour is 12]. The following are some examples. Enter hour: 1 Enter minute: 2 Enter second: 5 Enter AM or PM: AM Seconds since midnight: 3725 Enter hour: 11 Enter minute: 58 Enter second: 59 Enter AM or PM: PM Seconds since midnight: 86339 Enter hour: 12 Enter minute: 7 Enter second: 20 Enter AM or PM: AM Seconds since midnight: 440 Enter hour: 12 Enter minute: 14 Enter second: 57 Enter AM or PM: PM Seconds since midnight: 44097 Write a program to calculate the number of seconds since midnight. For example, suppose the time is 1:02:05 AM. Since there are 3600 seconds per hour and 60 seconds per minutes, it has been 3725 seconds since midnight (3600 * 1 + 2 * 60 + 5 = 3725). The program asks the user to enter 4 pieces of information: hour, minute, second, and AM/PM. The program will calculate and display the number of seconds since midnight. [Hint: be very careful when the hour is 12]. The following are some examples. Enter hour: 1 Enter minute: 2 Enter second: 5 Enter AM or PM: AM Seconds since midnight: 3725 Enter hour: 11 Enter minute: 58 Enter second: 59 Enter AM or PM: PM Seconds since midnight: 86339 Enter hour: 12 Enter minute: 7 Enter second: 20 Enter AM or PM: AM Seconds since midnight: 440 Enter hour: 12 Enter minute: 14 Enter second: 57 Enter AM or PM: PM Seconds since midnight: 44097
Expert Answer:
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date:
Students also viewed these programming questions
-
"internet radios" for streaming audio, and personal video recorders and players. Describe design and evaluation processes that could be used by a start-up company to improve the usability of such...
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
For students who enjoy the complexities of analytical syllogistics, here follow some theoretical questions whose answers can all be derived from the systematic application of the six rules of the...
-
Fortune magazine publishes an annual list of the 500 largest companies in the United States. The following data show the five states with the largest number of Fortune 500 companies (The New York...
-
How much of the following expenses are currently deductible by a cash basis taxpayer? a. Medical prescriptions costing $20 paid by credit card (medical expenses already exceed the 7.5% of AGI floor)....
-
On June 14, 1988, Thomas John Heck Jr. executed a note promising to pay Paul D. Heck \($51,000\) at 7 percent interest compounded annually. The note contains the following payment terms: Perpetual 90...
-
Completed Contract and Percentage of Completion with Interim Loss Reynolds Custom Builders (RCB) was established in 1985 by Avery Conway and initially built high-quality customized homes under...
-
Convert the following NFA into an equivalent DFA. Show every step. 91 e 93 90 e a b 92 b e
-
Most top executives and boards of directors are not engaged in the influenza pandemic (COVID-19) planning process and won't give it equal billing to other potential disruptions until at least one of...
-
What role does the process of socialization play in shaping individual personality, moral development, and gender identity, and how do various agents of socialization contribute to these aspects?
-
What differentiates the concepts of 'culture' and 'society,' and could you furnish an illustration of a distinct 'culture' alongside a corresponding 'society' for elucidation?
-
Assuming a typical density of mafic crust and a mantle density of 3.3 g/cm3, what percentage of a block of oceanic crust resting on the mantle would extend above the surface?
-
31. The slope distance and zenith angle measured from point P to point Q were 3905.604m and 47 42' 33", respectively. The instrument and rod heights were equal. If the elevation of point P is...
-
Marta, 32 years old, single, gives us the following information about some of her income obtained during this fiscal year. She received dividends from the shares of a pharmaceutical company, being...
-
A group of biologists is interested in surveying the abundance of barrel cacti (a type of plant) in a particular desert. They divide the desert area into 1200 equal-sized rectangular areas. Of these,...
-
A genetically engineered strain of Escherichia coli (E. coli) is used to synthesize human insulin for people suffering from type I diabetes mellitus. In the following simplified reaction scheme,...
-
Heres another peek ahead. In this chapter, you learned about integers and the type int. Java can also represent uppercase letters, lowercase letters and a considerable variety of special symbols....
-
What does the following code do? There is a statement after the recursive call which should be executed for each call. I 23456 public void printInt (int n) { if (n != 0) { printInt(n 1);...
-
Write an app that continuously displays Shape subclass objects on a Pane with random sizes, locations, stroke widths, fills and alpha transparencies. The Shapes should randomly move around the Canvas...
-
Using an economic balance sheet, which of the Laws current financial assets is most concerning from an asset allocation perspective? A. Equities B. Real estate C. Fixed income Raye uses a costbenefit...
-
Using the economic balance sheet approach, the Laws economic net worth is closest to: A. $925,000. B. $1,425,000. C. $1,675,000. Raye uses a costbenefit approach to rebalancing and recommends that...
-
Raye believes the previous advisers asset class specifications for equity and derivatives are inappropriate given that, for purposes of asset allocation, asset classes should be: A. diversifying. B....
Study smarter with the SolutionInn App