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

It has to run and compile in Netbeans. OO Design and OO Implement in JAVA an app

ID: 3638100 • Letter: I

Question

It has to run and compile in Netbeans.


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 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, TDD Style, a test plan for romanType class using NetBeans JUNIT
3. OO Implement the application in JAVA.


Explanation / Answer

please rate - thanks


import java.util.*;
public class RomanDriver
{public static void main(String[] args)
    { Scanner in=new Scanner(System.in);
    String input;
    char again='Y';
    while(again=='Y')
    {System.out.print("Enter a roman number: ");
    input=in.nextLine();
    romanType r=new romanType(input);
    System.out.print("Enter I to print as integer, R to print as Roman: ");
    if(Character.toUpperCase(in.next().charAt(0))=='I')
         decimal(r);
    else
         roman(r);
    System.out.print("Do you have another number(Y/N)? ");
    again=Character.toUpperCase(in.next().charAt(0));
    in.nextLine();
    }
   
   
         }
public static void decimal(romanType r)
{System.out.println("Your number in decimal is "+r.getDecimal());
}
public static void roman(romanType r)
{System.out.println("Your number in roman is "+r.getromanType());
}

}

--------------------------------

public class romanType
{private String roman;
private int decimal;
public romanType(String r)
    {int i,prev=1000;
    roman=r;
    decimal=0;
    for(i=0;i<r.length();i++)
          {switch(r.charAt(i))
             {case 'm':
                case 'M': decimal+=1000;
                         if(prev<1000)
                              decimal-=(2*prev);
                          prev=1000;
                          break;
                case 'd':               
             case 'D': decimal+=500;
                         if(prev<500)
                              decimal-=(2*prev);
                          prev=500;
                          break;
                case 'c':               
             case 'C': decimal+=100;
                         if(prev<100)
                              decimal-=(2*prev);
                          prev=100;
                          break;
            case 'l':
             case 'L':decimal+=50;
                         if(prev<50)
                              decimal-=(2*prev);
                          prev=50;
                          break;
                case 'x':               
             case 'X': decimal+=10;
                         if(prev<10)
                              decimal-=(2*prev);
                          prev=10;
                          break;
                case 'v':               
             case 'V': decimal+=5;
                         if(prev<5)
                              decimal-=(2*prev);
                          prev=5;
                          break;
                case 'i':               
             case 'I': decimal++;
                      prev=1;
             }
         }
}

    public int getDecimal()
    {return decimal;
         }

    public String getromanType()
    {return roman;
         }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote