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
Travka [436]
4 years ago
11

In this project you will demonstrate your knowledge of decision making blocks such as if statements. Objectives Building on ever

ything you have learned so far in this class, the objectives of this project are to demonstrate understanding of the following: • Input/output • Variables • Arithmetic expressions • Division and modulo • If-else statements • Equality and relational operators • Nested if-else statements • Code blocks and indentation Description Given the knowledge that there are 60 seconds in a minute, 60 minutes in an hour, and 24 hours in a day, you will prompt the user for the for the number of hours, minutes, and seconds as integer inputs, and your program will output the converted time so that the larger units are as large as possible. The possible output units are days, hours, minutes, and seconds. Make a note of the following: • Use singular and plural value names as appropriate, like 1 minute vs. 2 minutes. • Do not output a unit if its value is zero. For example: 2 hours and 1 second, NOT 0 days, 2 hours, 0 minutes and 1 second. • Your program must start by printing the welcome message: Welcome to the Time Conversion Calculator! • Your program should obtain the three inputs from the user, with the following prompts, in this order: Enter a number of hours: o Enter a number of minutes: • Enter a number of seconds: • You can assume that the user will never enter a negative number, but they can enter one or more O's. In the unique case that the user enters 0 for all three inputs, you should output: No time units to report. Refer to the sample runs below for how to format your output. Note that the time values are indented 4 spaces. Examples of a sample run: Welcome to the Time Conversion Calculator! Enter a number of hours: 1 Enter a number of minutes: 2 Enter a number of seconds: 3 Your time conversion is: 1 hour 2 minutes 3 seconds Goodbye! Welcome to the Time Conversion Calculator! Enter a number of hours: 0 Enter a number of minutes: 0 Enter a number of seconds: 0 Your time conversion is: No time units to report. Goodbye! Welcome to the Time Conversion Calculator! Enter a number of hours: 30 Enter a number of minutes: 20 Enter a number of seconds: 1000 Your time conversion is: 1 day 6 hours 36 minutes 40 seconds Goodbye!
Computers and Technology
1 answer:
barxatty [35]4 years ago
5 0

Answer:

print("Welcome to the Time Conversion Calculator")

#you need to check for each if user provided each of this inputs

while(True) :

   try:

       no_of_hours = int(input("Enter a number of hours:"))

       if type(no_of_hours) is int:

           break

       else:

           print('invalid input\n')

           no_of_hours = input('"Enter a number of hours:"\n')

   except ValueError:

       print('invalid amount\n')

       no_of_hours = input('"Enter a number of hours:"')

while(True) :

   try:

       no_of_minutes = int(input("Enter a number of minutes:"))

       if type(no_of_minutes) is int:

           break

       else:

           print('invalid input\n')

           no_of_minutes = input('"Enter a number of minutes:"\n')

   except ValueError:

       print('invalid amount\n')

       no_of_minutes = input('"Enter a number of minutes:"')

while(True) :

   try:

       no_of_seconds = int(input("Enter a number of seconds:"))

       if type(no_of_seconds) is int:

           break

       else:

           print('invalid input\n')

           no_of_seconds = input('"Enter a number of seconds:"\n')

   except ValueError:

       print('invalid input\n')

       no_of_seconds = input('"Enter a number of seconds:"')

# variables to keep track of days hours minutes

no_of_days = 0  

days = False

hours = False

minutes = False

seconds = False

hours_unit = "hours"

minutes_unit = "minutes"

seconds_unit = "seconds"

days_unit = "days"

#calculated values with initial values of zero

calc_minutes = 0

calc_hours = 0

if no_of_seconds >=  60:

   minutes= True

   calc_minutes = no_of_seconds // 60

   remaining_seconds =  no_of_seconds - (calc_minutes * 60)

   if remaining_seconds > 0:

         no_of_seconds = remaining_seconds

         seconds = True

         if no_of_seconds > 1:

            seconds_unit = "seconds"

         else:

            seconds_unit = "second"

no_of_minutes = no_of_minutes + calc_minutes

if no_of_minutes >=  60:

   hours = True

   calc_hours = no_of_minutes // 60

   remaining_minutes =  no_of_minutes - (calc_hours * 60)

   if remaining_minutes > 0:

         no_of_minutes = remaining_minutes

         minutes = True

         if no_of_minutes > 1:

            minutes_unit = "minutes"

         else:

             minutes_unit = "minute"

no_of_hours = no_of_hours + calc_hours

if no_of_hours >= 24:

   days = True

   no_of_days = no_of_hours // 24

   remaining_hours = no_of_hours -  (no_of_days * 24)

   if no_of_days > 1:

       days_unit = "days"

   else:

       days_unit = "day"

   if remaining_hours > 0:

       no_of_hours = remaining_hours

       minutes = True

       if no_of_hours > 1:

           hours_unit = "hours"

       else:

           hours_unit = "hour"

if no_of_days:

   print(str(no_of_days)+ " " + days_unit)

if no_of_hours:

   print(str(no_of_hours)+ " " + hours_unit)

if no_of_minutes:

   print(str(no_of_minutes)+ " " + minutes_unit)

if no_of_seconds:

   print(str(no_of_seconds)+ " " + seconds_unit)

print("Goodbye!")

Explanation:

This implementation is with the python programming language but can be rewritten in any language of your choose.

The program first forces users to provide the correct input using try catch.

it accepts the input, attempts to convert to int. if it fails, it repromts the user to enter the correct input

After uses boolean values to determine whether a value for seconds, minutes and hour is present inthe the question.

The calc values refers to the calculated values during runtime of minutes, hour and days

it then adds this calc values to the user inputs

You might be interested in
PLEASE ILL MARK BRAINLIEST
Minchanka [31]

Answer:

it is a capsid

5 0
3 years ago
Calculate the number of hours since the birthdate. Insert your calculation in cell C15. (hint: convert the number of days to num
Alik [6]

Answer:

Explanation:

To resolve this problem, first, we need the current date and a pass day, with these two values, we're going to use the formula called "DAYS" this formula returns the numbers of day between two dates, when we get the number of days, only we must multiply the result by 24, in this case, this represents the 24 hours in a day.

5 0
4 years ago
In this assignment, you will need to design a complete Black-Box testing plan for the following program. A computer science stud
murzikaleks [220]

Answer: sorry i need points to ask a question hope u understand...

Explanation:

8 0
3 years ago
The illegal downloading of software is called
Komok [63]

Piracy is the correct term

8 0
3 years ago
Read 2 more answers
What do the letters of the su command stand for? what can you do with su besides give yourself root privileges? "what can you do
Viefleur [7K]
Super User.
Execute commands that require root privileges.
Log in as the root user, then type 'passwd user'<span>
</span>
4 0
4 years ago
Other questions:
  • Packet ________ is a form of protection for your computer that looks at each packet that comes into your computer network. scree
    15·1 answer
  • A page can have High needs met rating even if it is not related To the topic of the query​
    9·1 answer
  • Usually, the same software that is used to construct and populate the database, that is, the DBMS, is also used to present ____.
    11·1 answer
  • A file with a .bat file extension is called a batch file. You can use a batch file to execute a group of commands, sometimes cal
    11·1 answer
  • Explain what is meant by information technology (IT). Explain what is meant by information systems (IS). Why is it important to
    7·1 answer
  • What is a type of machine-to-human communication?
    14·1 answer
  • A reputable, world-renowned auction house uses blockchain to verify the authenticity of paintings prior to placing them up for s
    7·1 answer
  • What is the processing speed for the second generation of computers​
    7·1 answer
  • Topic: Graphs.1.) Bob loves foreign languages and wants to plan his courseschedule for the following years. He is interested in
    8·1 answer
  • Why would a business consider using virtual machines?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!