# Microsoft Word - BCS230_Lab5_handout.docx Lab05-BCS230,M.Alrajab 1 BCS230 Lab5HandoutandAssignment This lab handout provides 3 tasks that students are required to attempt during lab session....

All the knowledge should relate to the textbook"c++ early objects ninth edition" written by Gaddis, Walters and Muganda

## Answer To: Microsoft Word - BCS230_Lab5_handout.docx Lab05-BCS230,M.Alrajab 1 BCS230...

Snehil answered on Mar 05 2020
lab5.cpp
#include "lab5.h"
#include using namespace std;
int main()
{
Converter converter;
int option;
do
{
cout

"1. Roman to int";
cout
"\n2. Int to roman";
cout
"\nEnter your choice (-1 to exit) : ";
cin
option;
switch(option)
{
case 1:
converter.romanToInteger();

eak;
case 2:
converter.integerToRoman();

eak;
case -1:

eak;
default:
cout
"Invalid option\n";
}
}while(option!=-1);
return 0;
}
Converter::Converter()
{
romanNum="I";
num=1;
romanSymbols = "IVXLCDM";
= {'I','V','X','L','C','D','M'}
}
void Converter::romanToInteger()
{
setRoman();
int length = romanNum.length();
int previous = 0;
bool e
or = false;
int nIndex = 0;
num = 0;
while( (e
or == false) && (nIndex < length) )
{
switch(romanNum[nIndex])
{
case 'M':
num += 1000;
if(previous < 1000)
{
num -= 2 * previous;
}
previous = 1000;

eak;
case 'D':
num += 500;
if(previous < 500)
{
num -= 2 * previous;
}
previous = 500;

eak;
case 'C':
num += 100;
if(previous < 100)
{
num -= 2 * previous;
}
...
SOLUTION.PDF