g n this program, you will prompt the user for three numbers. You need to check and make sure that all numbers are equal to or greater than 0 (can use an if or if/else statement for this). You will then multiply the last two digits together, and add the result to the first number. The program should then start over, once again asking for another three numbers. This program should loop indefinitely in this way. If the user enters a number lower than 0, remind the user that they need to enter a number greater than or equal to 0 and loop the program again.

Answers

Answer 1

Answer:

In Python:

loop = True

while(loop):

   nm1 = float(input("Number 1: "))

   nm2 = float(input("Number 2: "))

   nm3 = float(input("Number 3: "))

   if (nm1 >= 0 and nm2 >= 0 and nm3 >= 0):

       result = nm2 * nm3 + nm1

       print("Result: "+str(result))

       loop = True

   else:

       print("All inputs must be greater than or equal to 0")

       loop = True

Explanation:

First, we set the loop to True (a boolean variable)

loop = True

This while loop iterates, indefinitely

while(loop):

The next three lines prompt user for three numbers

   nm1 = float(input("Number 1: "))

   nm2 = float(input("Number 2: "))

   nm3 = float(input("Number 3: "))

The following if condition checks if all of the numbers are greater than or equal to 0

   if (nm1 >= 0 and nm2 >= 0 and nm3 >= 0):

If yes, the result is calculated

       result = nm2 * nm3 + nm1

... and printed

       print("Result: "+str(result))

The loop is then set to true

       loop = True

   else:

If otherwise, the user is prompted to enter valid inputs

       print("All inputs must be greater than or equal to 0")

The loop is then set to true

       loop = True


Related Questions

Other Questions
The length of a rectangle is shown below: On a coordinate grid from negative 6 to positive 6 on the x-axis and on the y-axis, two points A and B are shown. The point A is on ordered pair 1, 2, and the point B is on ordered pair negative 3, 2. A straight line joins the points A and B. If the area of the rectangle to be drawn is 12 square units, where should points C and D be located, if they lie vertically below the line that connects B and A, to make this rectangle? C(3, 2), D(1, 2) C(3, 1), D(1, 1) C(3, 4), D(1, 4) C(3, 5), D(1, 5) Sample Response: To find the image after a reflection over the x-axis, I would negate the y-coordinate. To find the image after a reflection over the y-axis, I would negate the x-coordinate. So, reflecting the point (5, 2) over the x- and y-axis, I would get (5, 2).Which did you include in your response? Check all that apply.Negate the y-coordinate.Negate the x-coordinate.Get the point (5, 2). What is a convergent boundary? How many miles is Hawaii from Florida? Why do the majority of Hindus live in India than Nepal Which of the following best represents the Income approach for computing GDP? *a.GDP = R+W+I+Pb.GDP = C+Ig+G=X-Mc.GDP = L+L+C+Ed.GDP = CEe.None of these. Use this equation for the next question:2NaOH + H2SO4 Na2SO4 + 2H20If a reaction produces 0.75 moles Na2SO4, how many moles of NaOH were used?0.75 moles NaOH2 moles NaOH.375 moles NaOH1.5 moles NaOH Describe the differences between the Arctic and Antarctica What is the slope of the line (-4,-1) (1,4) An element has five isotopes. Calculate the atomic mass of this element using the information below. Show all your work. Using the periodic table, identify the element this is likely to be and explain your choice. (18 pts)A) Isotope 1 mass: 64 amu; percent abundance: 48.89%B) Isotope 2 mass: 66 amu; percent abundance: 27.81%C) Isotope 3 mass: 67 amu; percent abundance: 4.11%D) Isotope 4 mass: 68 amu; percent abundance: 18.57%E) Isotope 5 mass: 70 amu; percent abundance: 0.62% Please answer this correctly without making mistakes I want ace expert and genius people to answer this correctly correctly without making mistakes Russians live on the North European Plain for all of the following reasons, EXCEPT.A. the North European Plain provides more temperate climates (incorrect)B. the North European Plain provides navigable riversC. the North European Plain provides more tundra goods for loggingD. the North European Plain provides fertile soils The perimeter of a rectangle is 48 cm. The length is 3 times as long as the width.What is the width of the rectangle?A. 4cm B.6cm C.8cm D.12.cm Natalie bought a 3 - pack of erasers for $1.47. How much did each eraser cost? how many countries in the world what is the rate unit for 1700 meters in 40 minutes please help If gas costs $1.95 per gallon, how many whole gallons of gas could you buy with $36.00? (Make sure to answer with a whole number.) Please help can some one explain to no how to get the answer pls help math!!!!!!!!!!!! Type using number words. (Remember to use a hyphen in your answer where needed.) 355