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
Can someone please help me answer this I can’t fail. tysm :)
vredina [299]

Answer:

  1. option d <em><u>b</u></em><em><u>e</u></em><em><u>c</u></em><em><u>a</u></em><em><u>u</u></em><em><u>s</u></em><em><u>e</u></em><em><u> </u></em><em><u>o</u></em><em><u>f</u></em><em><u> </u></em><em><u>y</u></em><em><u>o</u></em><em><u>u</u></em><em><u>. </u></em><em><u> </u></em><em><u> </u></em><em><u>b</u></em><em><u>l</u></em><em><u>a</u></em><em><u>a</u></em>

Explanation:

whu

5 0
3 years ago
Which option should Gina click to edit the text contained in a text box on a slide in her presentation?
topjm [15]
Text box
hope this helped
3 0
2 years ago
Blender is used by which video game team member?
prohojiy [21]

Answer:

The 2nd one

Explanation:

6 0
3 years ago
What tool listed below will be the most useful for developing presentation content?
eduard
An outline is going to be the best answer
8 0
4 years ago
In OOP terminology, an object's member variables are often called its ________ and its member functions can be referred to as it
sineoko [7]

Answer:Attributes, Methods

Explanation: According to the object-oriented programming, attribute serves as the purpose for defining the an elements features and functioning.It is usually in the form of collection of objects and also known as object's member variable.

Method in the OOP's concept is defined as technique that works on the object that consist of some data and certain features.It also clarifies about the usage or utilization of that data message according to their behavior.

5 0
4 years ago
Other questions:
  • A/An is a series of instructions or commands that a computer follows; used to create software
    10·2 answers
  • Write a statement that declares a prototype for a function add, which has two int parameters and returns an int .
    13·1 answer
  • Learning in a digital environment is also called learning.
    6·2 answers
  • Signals that can travel in only one direction on a medium are referred to as what type of signal?
    12·1 answer
  • HTML and CSS are computer languages used to create what?
    11·1 answer
  • Kathy would like to export a report that she created into an easy-to-use file format that is supported on multiple
    5·1 answer
  • According to the reading on the course web pages, the earliest usage of cooking began around _____ million years ago.
    12·1 answer
  • Every Java statement ends with: *<br><br> Period<br> Colon<br> Double quote<br> Semicolon
    11·2 answers
  • Which of the following statements is FALSE?
    10·2 answers
  • Part of the operating system core is responsible for controlling security, managing the file system, and providing a platform fo
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!