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
The term for an operator that may not evaluate one of its subexpressions is
Xelga [282]

Answer:

short-circuit

Explanation:

3 0
2 years ago
Where would the following URL most likely send you: http://www.whitehouse.gov/about/tours-and-events?
dezoksy [38]

Answer:

To an official government website containing information relating to tours and events of the White House.

Explanation:

Hope this helps! :D

6 0
2 years ago
To check for consciousness:
Lesechka [4]

The answer to your question is,

D) Check their pulse.

((Well, some people say to place your ear over the persons mouth and watch for a rise and fall of the chest-- but that's not an answer nor does that really go with any of the answers provided so..))


-Mabel <3

6 0
2 years ago
Read 2 more answers
Which method deletes a footer from a document?
Charra [1.4K]
The first option is your answer DOUBLE CLICK THE FOOTER REGION ECT
8 0
2 years ago
Hardware is often the most valuable asset possessed by an organization, and it is the main target of intentional attacks.
Elza [17]

Answer:

False is the correct answer for the above question

Explanation:

  • Hardware is a type of assets but its target is not for the intentional attack because it is used to make the organization
  • In any system or organization, there are two parts hardware and software and the hardware can be defined which can be touched that can be physical assets.
  • But the intentional attack is an attack that can be done from the internal source of the organization and the hardware can not do attack because it is a physical asset.
  • The above question states that the hardware is the cause of intentional attacks which is not correct as described above. Hence false is the correct answer.
6 0
3 years ago
Other questions:
  • Write a program that reads a list of scores and then assigns grades python
    9·1 answer
  • According to the order of operation in Excel: a. Excel performs exponentiation, then multiplication, then division, then subtrac
    10·1 answer
  • Use the Internet and other sources to research the two disadvantages of standard biometrics: cost and error rates. Select one st
    10·1 answer
  • Samantha was calculating a mathematical formula on an electronic spreadsheet. She used multiple values to recalculate the formul
    8·2 answers
  • How do i convert videos on the computer
    10·1 answer
  • Should the federal government have bug bounty programs? Why or why not?
    9·2 answers
  • Differences of a desktop computer and a laptop
    13·1 answer
  • Which relation is created with the primary key associated with the relationship or associative entity, plus any non-key attribut
    6·1 answer
  • A connection between files that allows data to be transferred from one file to another is a _______________________.
    6·1 answer
  • Detecta 1 problema
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!