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
NEED TO KNOW ASAP 50 POINTS<br><br> HOW DO YOU TURN IN AN IMOVIE ON GOOGLE CLASSROOM!?!?!?
RUDIKE [14]

Explanation:

1. make sure you've saved the video to your iPhone .

2. open the classroom app and locate the class you are to summit it

3. then, click the assignment comment and you see add an attachment.

4. it will bring a list, click files.

5. then in the next list, click photo.

6. then the list of the videos and pictures in your phone will show, click the video.

7. wait , because it might take a few minutes to upload.

8.after that, click hand in.

9. then, it will show a mark that the video has been handed in.

6 0
3 years ago
Read 2 more answers
You receive a check on which the numerical dollar amount does not match the dollar amount written in words.
givi [52]
Errrrrrrrrrrrr....... you can’t accept the cheque then, it’s wrong morally and legally. The cheque will bounce because you won’t accept it
8 0
4 years ago
Merlia is creating a presentation about her ethnic heritage for a homework assignment. Her friend John, a PowerPoint 2016 expert
Elanso [62]

Answer:

"apply to All"

Explanation:

The “Apply to All” button repeats a slide customization across all your slides, leaving them evenly. With this button, a modification made to one slide can be applied to all slides. This makes the power point presentation even and visually pleasing.

Since John told Merlia that it's often better to use the same slide transition consistently, we can conclude that John showed Merlia the "apply to all" button so she can apply the same transition to all slides in the presentation.

7 0
4 years ago
Gunther is filling in his own input mask. He wants to format the Social Security numbers of his clients. The field must contain
kati45 [8]
Last one I am not sure they
4 0
3 years ago
A. =A1&lt;= A14<br> B. Income – Expenses<br> C. SUM(A1:A14)<br> D. =150*.05
Tpy6a [65]
B that the anser yep i whent and reserch the the anser so itsb
8 0
4 years ago
Other questions:
  • R15. Suppose there are three routers between a source host and a destination host. Ignoring fragmentation, an IP datagram sent f
    8·1 answer
  • By generating and delivering timely and relevant information supported by networks, _____ creates new opportunities for conducti
    15·1 answer
  • Generally, websites ending in .edu, .gov, and .org are less likely to be biased, or to show preference toward a certain financia
    12·1 answer
  • A pointer is the memory address of a variable. FALSE TRUE
    9·1 answer
  • Fill in the blank with the correct response.
    5·2 answers
  • Guys help—How do you start a conversation with someone on brainly if that is a thing?
    6·1 answer
  • An understanding of basic psychology can help design and marketing teams ensure they meet their intended audience.
    15·2 answers
  • It is for employees to make mistakes that compromise the security of an organization’s computer devices and sensitive informatio
    10·2 answers
  • B. Directions: Fill in the blanks with the correct answer.
    13·1 answer
  • In response to an alert regarding a possible security incident, you are analyzing the logs for a web application. In the process
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!