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
To remove an embedded chart, you should _____ it and press the DELETE key. (Points : 2) move drag hide click
Readme [11.4K]
I think the answer would be "click" 
3 0
3 years ago
The type of software used widely in businesses to complete specific tasks is _____. application software programming language sy
postnew [5]

Answer:

Explanation:

System software. Not google!

7 0
3 years ago
Read 2 more answers
How do I add pictures to my questions on the mobile app?
taurus [48]
The camera is at the bottom of the screen,Take a pic
8 0
4 years ago
In 2014, what percentage of the world population has access to the internet?
AfilCa [17]

Answer:

At that time 43.9% of people have access to the global internet.

6 0
3 years ago
What happens? In word 2016 when the home ribbon tab is clicked on ?
RideAnS [48]

When you clicked on the ribbon tab in word 2016, you'd be brought to the home tab, where all of the basic controls are displaced for you to see.

Hope I could help! :)

5 0
3 years ago
Read 2 more answers
Other questions:
  • [Edhesive] 4.1 Code Practice
    5·2 answers
  • What New England industry quickly collapsed with the discovery of oil in Pennsylvania?
    11·2 answers
  • Which program has an indexed version of the NIST NSRL of MD5 hashes that can be imported to enhance searching for and eliminatin
    10·1 answer
  • Write a method called makeStars. The method receives an int parameter that is guaranteed not to be negative. The method returns
    14·1 answer
  • How to make an upside down exclamation point on mac?
    8·1 answer
  • True or false? The following deterministic finite-state automaton recognizes the set of all bit strings such that the first bit
    7·1 answer
  • When writing code, how can printing be useful?
    15·1 answer
  • I have no idea what I’m doing and this is due in 45 minutes
    7·1 answer
  • If you want the input gear to spin in the same direction as the output gear you must use a _______ gear.
    13·1 answer
  • Can You do this to help me plz 50 points
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!