Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 233 Weeks Ago, 5 Days Ago |
Questions Answered: | 12843 |
Tutorials Posted: | 12834 |
MBA, Ph.D in Management
Harvard university
Feb-1997 - Aug-2003
Professor
Strayer University
Jan-2007 - Present
Question:Write a C++ program that accepts a year written as a four-digit Arabic (ordinary)Â numeral and outputs the year written in Roman numerals.
Important:
Roman numerals are V for 5, X for 10, L for 50, C for 100, D for 500, and M for 1,000.
Recall that some numbers are formed by using a kind of subtraction of one Roman "digit"; for example, IV is 4 produced as V minus I, XL is 40, CM is 900, and so on.
A few sample years: MCM is 1900, MCML is 1950, MCMLX is 1960, MCMXL is 1940, MCMLXXXIX is 1989.
(Hints: Use division and mod.)
Â
Assume the year is between 1000 and 3000. Prompt the user again if the user types less than 1000 or bigger than 3000.
Your program should include a loop that lets the user repeat this calculation until the user says she or he is done.
Â
Define the following functions (value returning functions, Cally-by-Reference):
validateUserInput(): validates the user's input (must be between 1000 and 3000 and integers only).
returnRomanThousandsPlace(): returns roman numerals for the thousand place.
returnRomanHundredsPlace(): returns roman numerals for the hundreds place.
returnRomanTensPlace(): returns roman numerals for the tens place.
returnRomanOnesPlace(): returns roman numerals for the ones place.
Â
Â
**************************************************************************************
OUTPUTS:
**************************************************************************************
This program will accept a year written in four digit ordinary numeral and will
convert it into roman numerals.
Enter a year between 1000 and 3000:
5000
Â
The year entered is invalid. Enter a valid year between 1000 to 3000:
1952
Your number in roman numerals is: MCMLII
Â
Do you want to repeat the program again? y or n
y
-----------