1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Alika [10]
2 years ago
13

A day has 86,400 secs (24*60*60). Given a number in the range 1 to 86,400, output the current time as hours, minutes, and second

s with a 24-hour clock. For example, 70,000 sec is 19 hours, 26 minutes, and 40 seconds.Your program should have user input that is the number of seconds to convert, and then use that number in your calculations. Your output in C⁺⁺.
Computers and Technology
1 answer:
stellarik [79]2 years ago
5 0

Answer:

Here it the C++ program:

#include <iostream> //to use input output functions in the program

using namespace std; // to identify objects like cin, cout

int main() { //start of the body of main() function

   int time = 0; // time entered by the user

   int hour = 0; // to hold the value of hours

   int min = 0; //to hold the value of minutes

   int sec = 0; // to hold the value of seconds

   int remaining_time=0; // holds value of remaining time while conversion

cout << "Enter a time in seconds: "; //Prompts user to enter time in secs

cin >> time; //reads the value of time entered by the use

hour = time/3600; //divides the input time to 3600 to convert in hours

remaining_time = time%3600; // to calculate remaining time

min = remaining_time/60; // divides remaining time with 60 to get mins

remaining_time = remaining_time%60;

/* computes remaining time after converting the previous remaining time to minutes. */

       sec = remaining_time; // computes no of seconds

// time entered by user should be within this range

     if(time>=1 && time<=86400)

/*when if condition is true it displays the input seconds to hours minutes and seconds */

{cout<<"\nThe time is: "<<hour<<" hours, " <<min<<" minutes, and "<<sec<<" seconds\n"; }

else //when if condition evaluates to false

cout<<"Out of range";  } //displays out of range message

Explanation:

Everything is briefly explained in the comments given within the program.

The logic of this program is explained below.

Lets see how the given example works with this program. Suppose the user enters 96500. The message out of range is displayed as this value exceeds the range 1 to 86400.

Suppose user enters 70000. If condition evaluates to true. So this number is converted into hours, minutes as seconds as following:

To calculate hours this formula is used

                          hour = time/3600;

                                   = 70000/3600

                                   = 19

So the value of hour=19

Now the remaining_time variable works as a temporary variable to hold the remaining input after calculation of each conversion.

So after conversion to hour the remaining_time value is calculated as:

                         remaining_time = time%3600;

                                                    = 70000%3600

                                                    = 1600

mod here finds the remainder after conversion to hours as 70000/3600 has quotient 19 and remainder 1600.

Now the value of minutes is computed by this remaining time (value stored in remaining_time).

                       min = remaining_time/60;

                                     = 1600/60

                                     = 26

So the value of minutes is 26

Lets calculate remaining time:

                    remaining_time = remaining_time%60;

                                               = 1600%60

                                               = 40

Now the new value stored in remaining_time is 40

Now lets find the value of seconds:

                      sec = remaining_time;

                             = 40

As the new value of remaining_time is 40 so seconds=40

Finally the following message is displayed in output:

The time is: 19 hours, 26 minutes, and 40 seconds

You might be interested in
Which renewable resources are available at any time?​
nordsb [41]

Answer:

Explanation:

Renewable energy is fuel that comes from a source that can be replenished in a short amount of time. This includes solar, wind, water, geothermal power and bioenergy. While renewable energy sources may not always be available – for example, if there is no wind to drive wind turbines, or cloudy days that reduce solar energy – they play an important part in reducing the use of non-renewable resources. Furthermore, many of these resources do not emit greenhouse gases directly into the atmosphere.

8 0
3 years ago
The ____ is a tool in versions of microsoft office starting with office 2007 that consists of tabs, which contain groups of rela
tankabanditka [31]

The answer is A. The Ribbon is a UI component which was presented by Microsoft in Microsoft Office 2007. It is situated underneath the Quick Access Toolbar and the Title Bar. It includes seven tabs; Home, Insert, Page design, References, Mailing, Review and View. Every tab has particular gatherings of related summons.

6 0
3 years ago
Important tools used in the _____ phase of the DMAIC process include a project charter, a description of customer requirements,
pishuonlain [190]

Answer:

d. define

Explanation:

DMAIC is an acronym for Define, Measure, Analyze, Improve and Control is a data-driven improvement cycle used for improving processes and driving Six Sigma projects.

Important tools used in the define phase of the Define, Measure, Analyze, Improve, and Control (DMAIC) process include;

- A project charter.

- A description of customer requirements.

- Process maps.

- Voice of the Customer (VOC) data.

5 0
3 years ago
Enter the cube's edge: 4<br> The surface area is 96 square units.<br> Python
mr_godi [17]

Answer:

See the program code below.

Explanation:

def cube_SA(edge):

 edge = int(input("Enter the cube's edge: "))

 sa = edge * edge * 6

 print("The surface area is {} square units".format(sa))

cube_SA(4)

Best Regards!

5 0
3 years ago
Robert is leading a project online that includes students from different cultures. Two of the students spend most of the time li
enyata [817]

Answer:

A & C

Explanation:

8 0
3 years ago
Other questions:
  • A communications system connecting two or more computers is called a(n) ________.
    7·1 answer
  • Please help me I just bought a camera and I really wanna shoot in manual mode but I have like the basics down Shutter speed is l
    9·1 answer
  • This information is generally included on a fax cover sheet.
    15·1 answer
  • Enlist the various data analysis methods for study of Infrasonic waves, Seismic waves, Earthquake prone areas and how AI can be
    15·1 answer
  • Can u suggest me some Hindi movies that is on you-tube please suggest
    7·2 answers
  • In this assignment, you will write a program which merges two arrays of positive integers and removes any duplicate entries.
    8·1 answer
  • I need help under standing an assignment, I've contacted my teacher but I want to finish this class already. Here's the directio
    11·1 answer
  • A file name extension provides what information about a file?
    6·1 answer
  • Enhancement of job satisfaction and productivity are key characteristics of which theoretical perspective of work design? ​
    6·1 answer
  • The most important hardware device for connecting supercomputers over a wide area
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!