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
jonny [76]
3 years ago
9

A day has 86,400 seconds (24*60*60). Given a number of seconds in the range of 0 to 1,000,000 seconds, output the time as days,

hours, minutes, and seconds for a 24- hour clock. E.g., 70,000 seconds is 0 days, 19 hours, 26 minutes, and 40 seconds. Your function should output: Time is W days, X hours, Y minutes, and Z seconds. Your function should take the number of seconds as an integer parameter Your function MUST be named howLong.

Computers and Technology
2 answers:
nasty-shy [4]3 years ago
8 0

Answer:

def howLong(time):

   time = int(time)

   day = time // (24*3600)

   time = time % (24*3600)

   hour = time // 3600

   time = time % 3600

   minutes = time // 60

   time = time % 60

   seconds = time

   print("Time is {}days, {}hours, {}minutes, {}seconds".format(day, hour, minutes, seconds))

howLong(70000)

Explanation:

The programming language used is python 3.

The function howLong is defined and takes one argument. this argument is converted to an integer.

Two types of division are used:

1) Floor division(//): It returns the quotient answer, in which the digits after the decimal points are removes

2) Modulo division(%): Returns the remainder value.

The day, hours, minutes and seconds are evaluated using the modulo and floor division.

The result is printed to the screen.

A picture has been attached for you to see how the code runs.

HACTEHA [7]3 years ago
3 0

Answer:

// here is code in c++.

// include headers

#include <bits/stdc++.h>

using namespace std;

// function that calculate days, hours, minutes and seconds

void howLong(int sec)

{

   // find days

   int days=sec/86400;

   // update the seconds

   sec=sec%86400;

   // find hours

   int h=sec/3600;

   // update the seconds

   sec=sec%3600;

   // find minutes

   int min=sec/60;

   // update the seconds

   sec=sec%60;

   // output

   cout<<sec<<"seconds is "<<days<<" days,"<<h<<" hours,"<<min<<" minutes,and "<<sec<<"seconds."<<endl;

}

// driver function

int main()

{   // variable

   int sec;

   cout<<"Enter seconds:";

   // read the seconds

   cin>>sec;

   // call the function

   howLong(sec);

   

return 0;

}

Explanation:

Read the seconds from user.Then call the function howLong() with parameter seconds. In the function, it will first find the number of days by dividing the seconds with 86400 then update the remaining seconds.Next it will find the hours by dividing the remaining seconds with 3600 and update the remaining seconds.After that it will find the minutes by dividing the remaining seconds with 60 and update the remaining second.Then it will print the days, hours, minutes and seconds.

Output:

Enter seconds:70000

40seconds is 0 days,19 hours,26 minutes,and 40seconds.

You might be interested in
How many Brainliest in total can you give? Is there a limit to how many Brainliest you can give per day or per person?
Arturiano [62]

Answer:

Don't think so.

Explanation:

Oh! Can you please give me Branliest? I need it for an acheivement. It would help a lot if you did!

3 0
3 years ago
Read 2 more answers
Cute - or - ugly ???
maria [59]

Answer:

ur not ugly

Explanation:

6 0
3 years ago
Read 2 more answers
What's the component of the hardware?​
melisa1 [442]
Some component of the hardware are central processing unit (CPU), monitor, mouse, keyboard, computer data storage, graphics card, sound card, speakers and motherboard.

I’m sure theirs more but here’s so. Hope this helps!
7 0
3 years ago
Read 2 more answers
Hlo friends <br>what is full form of KEYBOARD ​
Vladimir79 [104]

<em>keys Electronic Yet Board Operating A to z Response Directly.</em>

8 0
3 years ago
Read 2 more answers
LotR Trivia- 1. What does LotR stand for?
Viefleur [7K]

Answer:

1. LotR means Lord of the Rings.

2. Eowyn is capable of winning and Arwen could put up a good fight.

3. No idea.

7 0
3 years ago
Other questions:
  • Pls help me. ask yourself what would jesus do...
    14·1 answer
  • You review a design written by somebody else for an application and you find these: - an interface Shape with a method draw() -
    7·1 answer
  • Which column and row references are updated when you copy the formula: =SUM($B5:D$15)?
    6·2 answers
  • WILL GIVE BRAINLIEST TO WHOEVER CAN HELP!!!!!!!!!!!!!!
    6·1 answer
  • Vocational schools are also called all of the following except:
    12·2 answers
  • How many bits are required to store the text of the number "97" in ASCII?'
    5·2 answers
  • What is the output of the following code snippet? int s1 = 20; if (s1 &lt;= 20) { System.out.print("1"); } if (s1 &lt;= 40) { Sy
    6·1 answer
  • Why should the Six-Step Process be considered as an iterative process?
    8·1 answer
  • In order to send a photo in a text message from your cell phone to your cousin's cell phone who lives in New Zealand, is it nece
    8·1 answer
  • In this lab, you will implement a temperature converter in JavaScript. The user may type a temperature in either the Celsius or
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!