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.

Respuesta :

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