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
Leo noticed that attackers have breached his wireless network. They seem to have used a brute-force attack on the WiFi protected
kakasveta [241]

Answer:

It is called a WPS brutal force attack.

Explanation:

Wired and wireless networks are both susceptible to attacks. The wired network, the advantage as a cable connection, is more secure than wireless networks, but wireless network also have security measures like the wifi protected set up (WPS).

WPS is used to connect to a network without passphrase, but with a key combination or a PIN.

Brutal force attacks are used on WPS to forcefully generate the PIN, using a third party software.

3 0
3 years ago
Consider two different implementations, M1 and M2, of the same instruction set. There are three classes of instructions (A, B, a
ANTONII [103]

Answer:

a) the average CPI for machine M1 = 1.6

the average CPI for machine M2 = 2.5

b) M1 implementation is faster.

c) the clock cycles required for both processors.52.6*10^6.

Explanation:

(a)

The average CPI for M1 = 0.6 x 1 + 0.3 x 2 + 0.1 x 4

= 1.6

The average CPI for M2 = 0.6 x 2 + 0.3 x 3 + 0.1 x 4

= 2.5

(b)

The average MIPS rate is calculated as: Clock Rate/ averageCPI x 10^6

Given 80MHz = 80 * 10^6

The average MIPS ratings for M1 = 80 x 10^6  / 1.6 x 10^6

= 50

Given 100MHz = 100 * 10^6

The average MIPS ratings for M2 = 100 x 10^6 / 2.5 x 10^6

= 40

c)

Machine M2 has a smaller MIPS rating

Changing instruction set A from 2 to 1

The CPI will be increased to 1.9 (1*.6+3*.3+4*.1)

and hence MIPS Rating will now be (100/1.9)*10^6 = 52.6*10^6.

7 0
3 years ago
Most people prefer to pay health insurance premiums rather than pay out of pocket for medical expenses because
oksano4ka [1.4K]
They may not have enough money for the bill at the time, and its easier to pay for insurance for unseen medical procedures.
7 0
3 years ago
Read 2 more answers
Can someone please tell me how to download tor browser onto a Linux laptop?
marta [7]

Answer:

Use windows

Explanation:

7 0
2 years ago
In your code editor, there is some code meant to output verses of the song "old macdonald had a farm. " when the code is working
iris [78.8K]

Using the knowledge in computational language in python it is possible to write a code that  meant to output verses of the song "old macdonald had a farm.

<h3>Writting the code:</h3>

def main():

   # Make a list containing animals and sounds.

   #     Element n is the animal and n+1 is its sound.

   animals = ['cow', 'moo', 'chicken', 'cluck', 'dog', 'woof', 'horse', 'whinnie', 'goat', 'blaaah']

   # For each animal/sound pair

   for idx in range(0, len(animals), 2):

       # Call song(), passing the animal/sound pair as parameters.

       song(animals[idx], animals[idx+1])

       print()

# song():

#   animal and sound are arguments

def song(animal, sound):

   # Call firstLast() for first line of song

   firstLast()

   # Call middleThree() for middle three lines, passing animal and sound

   middleThree(animal, sound)

   # Call firstLast() for last line of song

   firstLast()

# firstLast():

def firstLast():

   # Print "Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!"

   print("Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!")

# middleThree():

#   animal and sound are arguments

def middleThree(animal, sound):

   # Print middle three lines of song with passed animal and sound.

   print('And on that farm he had a {0}, Ee-igh, Ee-igh, Oh!'.format(animal))

   print('With a {0}, {0} here and a {0}, {0} there.'.format(sound))

   print('Here a {0}, there a {0}, everywhere a {0}, {0}.'.format(sound))

main()

See more about python at  brainly.com/question/18502436

#SPJ1

5 0
1 year ago
Other questions:
  • Consider a multiprocessor CPU scheduling policy. There are 2 options: 1) a singlecommon ready queue of jobs; when a CPU becomes
    8·1 answer
  • Which of the following is something that scientists often seek by using computer models and simulations?
    8·2 answers
  • In an oligopolistic market, consumer choice is?
    12·2 answers
  • 50 POINTS!!!!
    8·1 answer
  • ________________is a distribution of Linux Operating<br>system for desktop computers.<br>​
    15·1 answer
  • The BaseballPlayer class stores the number of hits and the number of at-bats a player has. You will complete this class by writi
    13·1 answer
  • Does nature behave the exact same way as fractals?
    15·1 answer
  • Find 10 real world challenges and their corresponding solutions
    13·1 answer
  • 11:25
    7·1 answer
  • What is boot sector virus​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!