1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#include <iostream>
#include <climits>
#include <cctype>
#include <string>
using namespace std;
int main(void)
{
char yesno;
unsigned short arabic_numeral, divide_thousand, divide_hundred, divide_ten,
divide_one, mod_thousand, mod_hundred, mod_ten, mod_one,
roman_thousand, roman_hundred, roman_ten, roman_one;
cout <<"\t\tWelcome to the Roman Numeral Program!\n";
cout <<"\nWould you like to convert numbers to Roman numerals today?\n";
cin >> yesno;
cin.ignore (INT_MAX, '\n');
//Allow user option to repeat the program as desired
while ('Y' == toupper(yesno) )
{
cout <<"\n\nPlease enter the number you would like to convert\n";
cin >> arabic_numeral;
divide_thousand = arabic_numeral / 1000;
mod_thousand = arabic_numeral % 1000;
divide_hundred = mod_thousand / 100;
mod_hundred = mod_thousand % 100;
divide_ten = mod_hundred / 10;
mod_ten = mod_hundred % 10;
divide_one = mod_ten / 1;
mod_one = mod_ten % 1;
roman_thousand = 1000 * divide_thousand;
roman_hundred = 100 * divide_hundred;
roman_ten = 10 * divide_ten;
roman_one = 1 * divide_one;
cout <<""<<roman_thousand<<", "<<roman_hundred<<", "<<roman_ten<<", "
<<roman_one<<"\n\n";
cout <<"\nWould you like to convert any more numbers to Roman
<<"numerals?\n;
cin >> yesno;
cin.ignore (INT_MAX, '\n');
}
if ('N' == toupper(yesno) )
{
cout <<"Thank you for using the Roman Numeral Conversion Program! Have";
<<"a great day!\n";
}
return 0;
}
|