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
olasank [31]
3 years ago
8

In this program you will read in the number of seconds and convert it to days, hours, minutes and remaining seconds.

Computers and Technology
1 answer:
ra1l [238]3 years ago
6 0

Answer:

In C++

#include <iostream>

using namespace std;

int main(){

   int days, hours, minutes, seconds;

   cout<<"Total seconds: ";

   cin>>seconds;

   if(seconds>0){

   days = seconds/86400;

   seconds%=86400; ;

   hours = seconds/3600;

   seconds%=3600;

   minutes = seconds/60;

   seconds %=60;

   cout<<days<<" days "<<hours<<" hours "<<minutes<<" minutes "<<seconds<<" seconds";}

   else{        cout<<"Total seconds must be greater than zero";    }

   return 0;}

Explanation:

Declare all variables as integer

int days, hours, minutes, seconds;

Prompt for input

   cout<<"Total seconds: ";

Get user inpur for seconds

   cin>>seconds;

If input is greater than 0

   if(seconds>0){

Calculate the number of days

   days = seconds/86400;

Get the remaining seconds

   seconds%=86400; ;

Calculate the number of hours

   hours = seconds/3600;

Get the remaining seconds

   seconds%=3600;

Calculate the number of minutes

   minutes = seconds/60;

Get the remaining seconds

   seconds %=60;

Print the required output

   cout<<days<<" days "<<hours<<" hours "<<minutes<<" minutes "<<seconds<<" seconds";}

If seconds is less than 1, then it is invalid

<em>    else{        cout<<"Total seconds must be greater than zero";    }</em>

You might be interested in
What does the acronym GIF stand for? Graphics Interface Format Graphics Interchange Format Going Into Files Gathering Informatio
Anna35 [415]
Graphics Interchange Format! :)
4 0
3 years ago
Read 2 more answers
Rewrite this method so that it avoids the use of a return statement:
olganol [36]
Sorry we chose 0 for the denominator
8 0
3 years ago
Altering grade records within a computer system is called
Cloud [144]
Altering grade records within a computer system is called forgery. The correct option among all the options given in the question is option "a". Any kind of altering using the computer without the consent of the proper authorities amounts to forgery. Forgery is a crime and a person can be jailed for such a serious offense.
4 0
3 years ago
Read 2 more answers
Which page format would you likely use for a photograph of a standing tree? AND why would you use that format?
VladimirAG [237]
Portrait since it is more tall then wide
4 0
3 years ago
Persons who have been given access to an installation can be counted on to be of no threat. true or false? (antiterrorism scenar
aliya0001 [1]
<span>The statement that "Persons who have been given access to an installation can be counted on to be of no threat" is false. If they are not honest enough, they could become the dangerous staff the company could ever had because he or she has access to everything, files, information, etc. That is why, in selecting a person to be trusted with such responsibility, he or she undergoes an intensive training.</span>
4 0
3 years ago
Other questions:
  • What was one of the first inventions that made it possible to communicate almost instantly?
    11·1 answer
  • When using a file name you have to use only lower case letters<br>true or false
    11·1 answer
  • Which of the following scenarios can best be addressed by operations management?
    11·1 answer
  • This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by
    8·1 answer
  • What is the range of possible sizes for side<br> x?<br> 4.0<br> 2.7
    8·1 answer
  • Int a = 1; int b = 0; int c = -1; if ((b + 1) == a) { b++; c += b; } if (c == a) { a--; b = 4; }
    7·1 answer
  • how does a demilitarized zone (dmz) work. A.By preventing a private network from sending malicious traffic to external networks
    10·1 answer
  • 8.
    9·1 answer
  • What happens when the electrons flowing through the light bulb change direction?
    11·1 answer
  • Data will zip through a 5G network much faster than through a 4G network because of the 10-fold difference in _____.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!