// Greg Gibas

// Advanced Programming C++ (Honors)

// Period 6

// November 13, 2000

// This program translates Arabic number

//     s into Roman numberals

#include 

#include 

void main()

    {

     // Declare variables that will be used

     int ones, tens, hundreds, thousands, temp, input, x;

     char rOnes[100] = "";

     char rTens[100] = "";

     char rHundreds[100] = "";

     char rThousands[100] = "";

     char *rTemp;

     // Display a friendly prompt

     cout << "\n *****************************\n";

     cout << " * A R A B I C - R O M A N *\n";

     cout << " *C O N V E R T E R*\n";

     cout << " * - - - - - - - - - - - - - *\n";

     cout << " * Coded by Greg Gibas *\n";

     cout << " *****************************\n";

     cout << "\n\n Type in any Arabic number (upto 4 digits), and this program ";

     cout << "\n will convert it into a Roman Numeral. When you want to exit,\n";

     cout << " type in the number \"0\" by itself. \n\n";

     for(;;)

         {

         cout << " >> ";

         cin >> input;

         // if the user entered the number 0, end the loop

         if(input==0) break;

         cout << "\n\nArabic : " << input;

         // Seperate the number into thousands, hundreds, tens, and ones places

         thousands = input/1000;

         hundreds = (input-(thousands*1000))/100;

         tens= (input-(thousands*1000 + hundreds*100))/10;

         ones= (input-(thousands*1000 + hundreds*100 + tens*10));

         temp = 0;

         // Calculate the thousands

         while(temp!=thousands)

             {

             rTemp = "M";

             strcat(rThousands, rTemp);

             temp++;

             }

             // Clean Out The Variable

             temp = 0;

             // Convert the hHundreds place

             if(temp!=hundreds)

                 {

                 if(hundreds==1) strcpy(rHundreds, "C");

                 if(hundreds==2) strcpy(rHundreds, "CC");

                 if(hundreds==3) strcpy(rHundreds, "CCC");

                 if(hundreds==4) strcpy(rHundreds, "CD");

                 if(hundreds==5) strcpy(rHundreds, "D");

                 if(hundreds==6) strcpy(rHundreds, "DC");

                 if(hundreds==7) strcpy(rHundreds, "DCC");

                 if(hundreds==8) strcpy(rHundreds, "DCCC");

                 if(hundreds==9) strcpy(rHundreds, "CM");

                 }

                

                 // Clean Out The Variable

                 temp = 0;

                

                // Convert the Tens place

                 if(temp!=tens)

                     {

                     if(tens==1) strcpy(rTens, "X");

                     if(tens==2) strcpy(rTens, "XX");

                     if(tens==3) strcpy(rTens, "XXX");

                     if(tens==4) strcpy(rTens, "XL");

                     if(tens==5) strcpy(rTens, "L");

                     if(tens==6) strcpy(rTens, "LX");

                     if(tens==7) strcpy(rTens, "LXX");

                     if(tens==8) strcpy(rTens, "LXXX");

                     if(tens==9) strcpy(rTens, "XC");

                     }

                    

                    // Clean Out The Variable

                     temp = 0;

                    

                     // Convert the Ones place

                     if(temp!=ones)

                         {

                         if(ones==1) strcpy(rOnes, "I");

                         if(ones==2) strcpy(rOnes, "II");

                         if(ones==3) strcpy(rOnes, "III");

                         if(ones==4) strcpy(rOnes, "IV");

                         if(ones==5) strcpy(rOnes, "V");

                         if(ones==6) strcpy(rOnes, "VI");

                         if(ones==7) strcpy(rOnes, "VII");

                         if(ones==8) strcpy(rOnes, "VIII");

                         if(ones==9) strcpy(rOnes, "IX");

                         }

                        

                         // Display the answer in Roman Numerals

                         cout << "\nRoman : " << rThousands << rHundreds << rTens << rOnes;

                         cout << "\n\n";

                         // Clean out these variables to prepare for the next number

                         strcpy(rOnes, "");

                         strcpy(rTens, "");

                         strcpy(rHundreds, "");

                         strcpy(rThousands, "");

                    }

                    

                    // Give an exit message then wait for a 

                    //     key to exit

                     cout << "\n\nGoodbye!\n";

                     return;

                }