Roman Number Generator. Enter 0 to quit. Enter a number between 1 and 9,999 Roman Numerals:I Enter a number between 1 and 9,999: 2 Roman Numerals: II Enter a number between 1 and 9,999 3 Roman Numerals: III Enter a number between 1 and 9,999: Roman Numerals: IX Enter a number between 1 and 9,999 28 Roman Numerals: XXVIII Enter a number between 1 and 9,999: 17 Roman Numerals XVII Enter a number between 1 and 9,999: 2017 Roman Numerals: MMXVII Enter a number between 1 and 9,999: Roman Numerals: Bye.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Note: Numbers greater then 3,999 require symbols with lines over letters. We can't use these, so use lower case v for 5000 and x for 10000.

The first 10 numbers are

  • I
  • II (1+1=2)
  • III (1+1+1=3)
  • IV (5-1=4)
  • V
  • VI (5+1=6)
  • VII (5+2=7)
  • VIII (5+3=8)
  • IX (10-1=9)
  • X

This pattern repeats for larger numbers. For example to create 47, we need to figure out 40 first. 4 was IV, there are equivalent 1, 5, and 10 symbols for the tens place. We can determine that 40 is XL since X is 10 and L is 50. We then combine this with 7 from above to get XLVII. Every value can be broken down into this basic 1-9 pattern just using different symbols.

(1) Create a function roman(num, one, five, ten) that takes a number between 1 and 9. The function returns a string with the roman representation using the strings given for the one, five, and ten symbols. If a number outside the range is given return the empty string "".

For example, Executing roman(4,"X","L","C") should return "XL"

(2) Create a function roman_num(num) that takes a number between 1 and 9,999 and returns it as a Roman Numeral. Return an empty string outside the range. Use the function from the previous step.

For example, executing roman_num(47) should return "XLVII".

(3) Create a main program that asks users for a number and prints it as a Roman Numeral. The program should run until the user enters 0. Use the functions from the previous steps. Print "Bye." when you exit. Remember to use if name=="main": so ZyBooks can test your functions.

Here is an example execution trace.

 

This code is for Python!

Roman Number Generator. Enter 0 to quit.
Enter a number between 1 and 9,999
Roman Numerals:I
Enter a number between 1 and 9,999:
2
Roman Numerals: II
Enter a number between 1 and 9,999
3
Roman Numerals: III
Enter a number between 1 and 9,999:
Roman Numerals: IX
Enter a number between 1 and 9,999
28
Roman Numerals: XXVIII
Enter a number between 1 and 9,999:
17
Roman Numerals XVII
Enter a number between 1 and 9,999:
2017
Roman Numerals: MMXVII
Enter a number between 1 and 9,999:
Roman Numerals:
Bye.
Transcribed Image Text:Roman Number Generator. Enter 0 to quit. Enter a number between 1 and 9,999 Roman Numerals:I Enter a number between 1 and 9,999: 2 Roman Numerals: II Enter a number between 1 and 9,999 3 Roman Numerals: III Enter a number between 1 and 9,999: Roman Numerals: IX Enter a number between 1 and 9,999 28 Roman Numerals: XXVIII Enter a number between 1 and 9,999: 17 Roman Numerals XVII Enter a number between 1 and 9,999: 2017 Roman Numerals: MMXVII Enter a number between 1 and 9,999: Roman Numerals: Bye.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 10 steps with 8 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education