Flowgorithm, Design a program that prompts the user to enter a number within the range of 1 through 10. The program should display the Roman numeral version of that number. If the number is outside the range of 1 through 10, the program should display an error message?

Respuesta :

Answer:

Step by step code along with explanation and output is given below

Explanation:

We can solve this problem using if elif else approach

def main():

# prompts the user to enter an integer from 1 to 10

 num = int (input('Enter a number in the range of 1 to 10:\n'))

# using the if elif print out the roman numeral from 1 to 10

 if num == 1:

   print ('Roman Numeral for 1 is I')

 elif num == 2:

   print ('Roman Numeral for 2 is II')

 elif num == 3:

   print ('Roman Numeral for 3 is III')

 elif num == 4:

   print ('Roman Numeral for 4 is IV')

 elif num == 5:

   print ('Roman Numeral for 5 is V')

 elif num == 6:

   print ('Roman Numeral for 6 is VI')

 elif num == 7:

   print ('Roman Numeral for 7 is VII')

 elif num == 8:

   print ('Roman Numeral for 8 is VIII')

 elif num == 9:

   print ('Roman Numeral for 9 is IX')

 elif num == 10:

   print ('Roman Numeral for 10 is X')

# using the else print out error message whenever user enters any other number not listed above

 else:

   print ('Error! Wrong Input')

# call the main function

main()

Output:

Enter a number in the range of 1 to 10:

6

Roman Numeral for 6 is VI

Enter a number in the range of 1 to 10:

15

Error! Wrong Input

Ver imagen nafeesahmed
Ver imagen nafeesahmed