added a UI and small changes

I added a UI and maked small changes.
This commit is contained in:
Christian Bender
2018-03-17 16:37:23 +01:00
committed by GitHub
parent 5d6b45ef3c
commit 6ea11b31d6

View File

@@ -10,13 +10,13 @@ using namespace std;
//This functions fills a string with character c, n times and returns it //This functions fills a string with character c, n times and returns it
string fill( char c, int n ) string fill( char c, int n )
{ {
string s; string s = "";
while( n-- ) s += c; while( n-- ) s += c;
return s; return s;
} }
//to convert to lowercase Roman Numeral //to convert to lowercase Roman Numeral
// the function works recursively
string tolowerRoman( int n ) string tolowerRoman( int n )
{ {
if( n < 4 ) return fill( 'i', n ); if( n < 4 ) return fill( 'i', n );
@@ -36,7 +36,7 @@ string tolowerRoman( int n )
} }
//to convert to uppercase Roman Numeral //to convert to uppercase Roman Numeral
// the function works recursively
string toupperRoman( int n ) string toupperRoman( int n )
{ {
if( n < 4 ) return fill( 'I', n ); if( n < 4 ) return fill( 'I', n );
@@ -61,6 +61,8 @@ int main()
{ {
int n; int n;
cout << "\t\tRoman numbers converter\n\n";
cout << "Type in decimal number between 0 up to 4000 (exclusive): ";
cin >> n; cin >> n;
cout << n << " in Upper Roman Numerals is " << toupperRoman(n) << "\n"; cout << n << " in Upper Roman Numerals is " << toupperRoman(n) << "\n";
cout << n << " in Lower Roman Numerals is " << tolowerRoman(n) << "\n"; cout << n << " in Lower Roman Numerals is " << tolowerRoman(n) << "\n";