Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(I have the program, but I would like to know the test program where all the tes

ID: 3637811 • Letter: #

Question

(I have the program, but I would like to know the test program where all the tests a,b and c are passing in visual studio 2008 using visual assert.)

Design and implement in C++ an application that converts a number entered in Roman numerals to decimal form. Your application should consist of a class, romanType. An object of romanType should do the following:
a. Store the number as a Roman numeral.
b. Convert and store the number into decimal form.
c. Print the number as a Roman numeral or decimal number as requested by the user.
Write two separate functions— one to print the number as a Roman numeral and the other to print the number as a decimal number.
The decimal values of the Roman numerals are:
M 1000
D 500
C 100
L 50
X 10
V 5
I 1
Remember, a larger numeral preceding a smaller numeral means addition, so LX is 60. A smaller numeral preceding a larger numeral means subtraction, so XL is 40. Any place in a decimal number, such as the 1s place, the 10s place, and so on, requires from zero to four Roman numerals.
Test your program using the following Roman numerals: MCXIV, CCCLIX, and MDCLXVI.


2. Develop and run a test plan for romanType class using CppUNIT Visual Assert
You need to run these into a Visual Studio 2008 project.

(Here is my program)
// RomanType Header FIle
// romanType.h
#include<string>
using namespace std;
class romanType
{
public :
romanType( string = "" );
void setRoman( string );
void convertToDecimal();
void printRoman();
void printDecimal();
private:
string roman;
int decimal;
}; // end class definition ofromanType

// implementationfile romanTypeImp.cpp
#include<iostream>
#include "romanType.h"
using namespace std;
romanType::romanType( string myRoman )
{
roman = myRoman;
decimal = 0;
} // end constructor romanType
void romanType::setRoman( string myRoman )
{
roman = myRoman;
decimal = 0;
} // end function setRoman
void romanType::convertToDecimal()
{
char romans[7] = { 'M', 'D', 'C', 'L','X', 'V', 'I'};
int decimals[ 7 ] = { 1000, 500, 100,50, 10, 5, 1 };
int j, pos;
size_t len = roman.length();
// process the numeral
for ( unsigned int i = 0; i < len -1; i++ )
{
// find the roman letter
for ( pos= 0; pos < 7; pos++ )
if ( roman.at( i ) == romans[ pos ] )
break;
// check for validity of the roman letter
if ( pos< 7 )
{
// check the next roman letter's value
for ( j = 0; j < pos; j++ )
if ( roman.at( i + 1 ) == romans[ j ] )
break;
// add or subtract the dec. val
// according to the values of j and pos
if ( j == pos )
decimal += decimals[ pos ];
else
decimal -= decimals[ pos ];
}
} // endfor
// process the last numeralvalue
for ( j = 0; j < 7; j++ )
if (roman.at( len - 1 ) == romans[ j ] )
break;
//add the dec. val of roman letter tothe dec. number
decimal += decimals[ j ];
} // end functionconvertToDecimal
void romanType::printRoman()
{
cout << " The roman numeralis " << roman;
} // end function printRoman
void romanType::printDecimal()
{
cout << " The decimalequivalent of the "
<< "given roman numeral is " << decimal;
} // end function printDecimal

// Main program
#include<iostream>
#include "romanType.h"
using namespace std;
int main() // function main beginsprogram execution
{
// let the user know aboutthe program
cout << " Program thatconvert Roman Numeral"
<< " into decimal form.";
// instantiate object of typeromanType
romanType r;
string rns[ 3 ] = { "CCCLIX","MCXIV", "MDCLXVI" };
for ( int i = 0; i < 3; i++)
{
// set the roman numeral string
r.setRoman( rns[ i ] );
// convert the roman numeral into decimal form
r.convertToDecimal();
// print the roman numeral
r.printRoman();
// print the decimal form of numeral
r.printDecimal();
} // endfor
cout << " ";
system( "pause" );
return 0; // indicate program executedsuccessfully
} // end of function, main

Explanation / Answer

Hi, my friend i think u should try to get the Roman Numerals from the user and the tests u r doing to be examples for what the program do so after the for loop u have add this string str; cout