{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

program 4 - /Item/Pasting this table in/your writeup/Your...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
//Item Points Actual // Possible Points P //Pasting this table in 1 //your writeup / //Your name 1 //Description 1 //Function Comments 7 //(parameters, pre/post //conditions, descriptions) / //Variable comments 2 //Use of functions 4 //Roman to English 10 1 //English to Roman 10 1 //Handles Multiple 1 //Expressions / //3 test cases 3 /******************************************************************************/ / //Tom Nanke //CIS 150-001 //11-20-07 //Program 4 //This is a roman number calculator program. It can add, subtract, or multiply //roman numbers. The user inputs a roman number, followed by the operator that //he/she wants to use, followed by another roman number. The program then reads //that expression, converting the roman numbers into integer numbers, does the //math of the operation, and then converts the answer back into a roman number, //which is what is output onto the screen. / #include <iostream> # using namespace std; u int romanToDecimal(int &number); //Function prototype void decimalToRoman(); //Function prototype / char roman[8]={'I','V','X','L','C','D','M','0'}; //array of possible characters the user can enter that will be needed / int main() { int number; //Initialization of the the variable number, which is the //integer number that the romanToDecimal function will return. int index=0; //Initialization of the variable index, which will represent //the location of the character in the roman array. cout<<"Enter a roman expression. Enter the number 0 at any point"<<endl;
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
cout<<" to exit the program: "; cin>>roman; c romanToDecimal(number); //Function call cout<<"The answer is: "; decimalToRoman(); //Function call cout<<endl; c while(roman[index]!='0') //Loop that executes until the user enters 0. { cout<<"Enter a roman expression: "; cin>>roman; c romanToDecimal(number); //Function call cout<<"The answer is: "; decimalToRoman(); //Function call cout<<endl; } return 0; r } /******************************************************************************/ / int romanToDecimal(int &number)
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern