1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Natasha_Volkova [10]
3 years ago
13

Design a RomanNumerals class that takes a number within 1 to 10 and display the Roman numeral version of that number (I, II, III

, IV, V … X). If the number entered by the user is outside the range of 1-10, the program should display an error message. Code a driver class RomanNumeralsApp to test the class by asking user to enter a number, creating an object of RomanNumerals and calling its methods getNumber, setNumber, convertNum, and displayResult to perform the described task.
Computers and Technology
1 answer:
Alla [95]3 years ago
7 0

Answer:

Explanation:

The following code is written in Java. It  creates a RomanNumberals class with all of the requested methods, including a convertNum method and displayResults method. The user is then asked to input a number within the main method. A RomanNumeral object is created, passed the userInput and all of it's methods are called for testing. A test output can be seen in the attached image below.

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter a number: ");

       int number = in.nextInt();

       RomanNumerals romanNumeral1 = new RomanNumerals();

       romanNumeral1.setNumber(number);

       System.out.println("Test getNumber Method: " + romanNumeral1.getNumber());

       romanNumeral1.convertNumber();

       romanNumeral1.displayResult();

   }

}

class RomanNumerals {

   int number;

   String romanNumeral;

   public RomanNumerals() {

   }

   public int getNumber() {

       return number;

   }

   public void setNumber(int number) {

       this.number = number;

   }

   public void convertNumber() {

       switch (this.number) {

           case 1: romanNumeral = "I"; break;

           case 2: romanNumeral = "II"; break;

           case 3: romanNumeral = "III"; break;

           case 4: romanNumeral = "IV"; break;

           case 5: romanNumeral = "V"; break;

           case 6: romanNumeral = "VI"; break;

           case 7: romanNumeral = "VII"; break;

           case 8: romanNumeral = "VIII"; break;

           case 9: romanNumeral = "IX"; break;

           case 10: romanNumeral = "X"; break;

           default: System.out.println("Not a valid number"); break;

       }

   }

   public void displayResult() {

       System.out.println("Number " + this.number + " is represented as " + this.romanNumeral);

   }

}

You might be interested in
The AND operator is a disjunction and the OR operator is a conjunction.
qwelly [4]

Answer:

True but it might be false but i think is true

8 0
3 years ago
The term “computer literacy” dates back to what decade? <br> 1960s<br> 1970s<br> 1980s<br> 1990s
NNADVOKAT [17]
1970-80s which is when some of the first computers were created like apple computers which looked like a giant cube and a rectangle on the side which is very different than what we have today.

Hope this helps!
3 0
4 years ago
Memory unit is amount of data that can be stored in a storage unit true or false​
vladimir1956 [14]

Answer:

amount of data and the researcher in a bit and I'll get you can use my card if I'm going well for us the best part is a copy sir pasenya the same thing I

4 0
3 years ago
Which of the following is the single best rule to enforce when designing complex passwords?
saw5 [17]

Answer:

B. Longer passwords

Explanation:

If the password is longer, it requires more incorrect attempts to find it, so the system could identify a potential hacker attempt. Smaller but more complex passwords could be identified by mistype or forgotten passwords.

3 0
3 years ago
Concept of national sovereignty was established by the
Eduardwww [97]

Answer:

Explanation:

Thomas Hobbes. He was the one who provided the term with its modern meaning.

7 0
4 years ago
Other questions:
  • What is the unit of electric power?
    15·1 answer
  • What port does the DarkComet malware listen on?
    15·1 answer
  • Code a Boolean expression that tests if a decimal variable named currentSales is greater than or equal to 1000 or a Boolean vari
    11·1 answer
  • Rob Janoff believes that technology should not be used too
    11·1 answer
  • What would you need to have on your foley stage
    9·1 answer
  • Los antivirus no son infalibles y en ocasiones pueden darnos:
    5·1 answer
  • The four compass points can be abbreviated by single-letter strings as "N", "E", "S", and "W". Write a function turn_clockwise t
    15·1 answer
  • Write a script that checks to see if at least one argument has been given on the command line and tests whether the argument is
    5·1 answer
  • Which hardware component interprets and carries out the instructions contained in the software.
    12·1 answer
  • The term ____ refers to the use of a single unifying device that handles media, internet, entertainment, and telephone needs.Dig
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!