I would like to convert my C++ program to Java, it must run and compile in netbeans.(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 of romanType(romanType.cpp)#include<iostream>#include "romanType.h"using namespace std;romanType::romanType( string myRoman ){roman = myRoman;decimal = 0;} // end constructor romanTypevoid romanType::setRoman( string myRoman ){roman = myRoman;decimal = 0;} // end function setRomanvoid 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 numeralfor ( unsigned int i = 0; i < len -1; i++ ){// find the roman letterfor ( pos= 0; pos < 7; pos++ )if ( roman.at( i ) == romans[ pos ] )break;// check for validity of the roman letterif ( pos< 7 ){// check the next roman letter's valuefor ( 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 posif ( j == pos )decimal += decimals[ pos ];elsedecimal -= decimals[ pos ];}} // endfor// process the last numeralvaluefor ( j = 0; j < 7; j++ )if (roman.at( len - 1 ) == romans[ j ] )break;//add the dec. val of roman letter tothe dec. numberdecimal += decimals[ j ];} // end functionconvertToDecimalvoid romanType::printRoman(){cout << "nntThe roman numeralis " << roman;} // end function printRomanvoid romanType::printDecimal(){cout << "ntThe decimalequivalent of the "<< "given roman numeral is " << decimal;} // end function printDecimal(Main)#include<iostream>#include "romanType.h"using namespace std;int main() // function main beginsprogram execution{// let the user know aboutthe programcout << "nntProgram thatconvert Roman Numeral"<< " into decimal form.";// instantiate object of typeromanTyperomanType r;string rns[ 3 ] = { "CCCLIX","MCXIV", "MDCLXVI" };for ( int i = 0; i < 3; i++){// set the roman numeral stringr.setRoman( rns[ i ] );// convert the roman numeral into decimal formr.convertToDecimal();// print the roman numeralr.printRoman();// print the decimal form of numeralr.printDecimal();} // endforcout << "nnt";system( "pause" );return 0; // indicate program executedsuccessfully} // end of function, main(Here is my Program Assignment)OO Design and OO Implement in JAVA 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 1000D 500C 100L 50X 10V 5I 1Remember, 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. Anyplace 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, TDD Style, a test plan for romanType class using NetBeans JUNIT3. OO Implement the application in JAVA.


Are there any questions left?
New questions in the section Engineering
Sign up for the IQClass
Answers from experts with no ads!
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Made with love
This website uses cookies to make IQClass work for you. By using this site, you agree to our cookie policy

Pleased to see you again

IQClass unlocks the learning potential of every child
  • Master useful skills
  • Improve learning outcomes
  • Share your knowledge
Create an account
Sign in
Recover lost password
Or log in with

Create an account

IQClass unlocks the learning potential of every child
  • Master useful skills
  • Improve learning outcomes
  • Share your knowledge
Create an account
Sign Up
Or sign up with
By signing up, you agree to the Terms of use and Privacy policy.
Looking for an answer to a question you need help with?
you have баллов