display the roman numeral version of that number (I, II, III,
IV, V … X). If the number entered by user is outside the range of
1-10, the program should display an error message. Code a driver
class RomanNumeralsAppto test the class by asking user to enter a
number, creating an object of RomanNumeralsand calling its methods
getNumber, setNumber, convertNumand displayResultto perform the
described task.
Coding Requirements:
•
Must use required/meaningful names for fields, variables, methods
and classes.
•
Must document each of your source code (see example in the next
slide)
•
Must separate operation class RomanNumeralsfrom the driver
class
RomanNumerals.java
public class RomanNumerals {
int number;
String romanNum;
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public void convertNum(int number){
if(number==1)
this.romanNum="I";
else if(number==2)
this.romanNum="II";
else if(number==3)
this.romanNum="III";
else if(number==4)
this.romanNum="IV";
else if(number==5)
this.romanNum="V";
else if(number==6)
this.romanNum="VI";
else if(number==7)
this.romanNum="VII";
else if(number==8)
this.romanNum="VIII";
else if(number==9)
this.romanNum="IX";
else if(number==10)
this.romanNum="X";
}
public String displayResult(){
return this.romanNum;
}
}
RomanNumeralsApp.java
import java.util.Scanner;
public class RomanNumeralsApp { //driver class
public static void main(String[] args) {
RomanNumerals numerals=new
RomanNumerals(); // create instance
Scanner scanner=new
Scanner(System.in);
System.out.println("Enter a number
: ");
int N=scanner.nextInt();
if(N>0 &&
N<11){
numerals.setNumber(N); // set number
numerals.convertNum(numerals.getNumber()); // convert number into
roman numeral
System.out.println("Roman Numeral of "+numerals.getNumber()+" is
"+numerals.displayResult()); // display result
}
else{
System.out.println("Error : Number outside of range 1-10"); //
error
}
scanner.close();
}
}
Output :
display the roman numeral version of that number (I, II, III, IV, V … X). If...
i need help with a mips program to to covert roman numerals to
real numbers
Lab 4: Roman Numeral Conversion Part A: Due Sunday, 19 May 2019, 11:59 PM Due Friday, 24 May 2019, 11:59 PM Part B: Minimum Submission Requirements Ensure that your Lab4 folder contains the following files (note the capitalization convention): o Diagram.pdf o Lab4. asm O README.txt Commit and push your repository Lab Objective In this lab, you will develop a more detailed understanding of how...
Part I: Problem: Code the following in Java: Candy Class -price -number of pounds sold Create the following methods: -Two constructors – default and second - accessor and mutator methods for each of the fields. - check for invalid price. Negative price is invalid (use if then else and display error message) - a method named userInput to get user input for all the fields. - check for invalid price. Negative price is invalid (use a loop to prompt the...
need help in Java Now we’ll continue our project by writing a Facebook class that contains an ArrayList of Facebook user objects. The Facebook class should have methods to list all of the users (i.e. print out their usernames), add a user,delete a user, and get the password hint for a user You will also need to create a driver program. The driver should create an instance of the Facebook class and display a menu containing five options: list users...
Using visual Studio C# 1. In one text box, your program must except a letter (A-Za-z), a number (0-9), or a special symbol (#@!$%^&*). 2. If the user enters a letter, call a module, displayLetter. Pass the letter they entered into the module. The module will then display a figure (stick man?) using the letter the person entered. 3. If the user enters a number, call a module displayNumber. Pass the number they entered into the module. The module will...
LAB1 PART 1 FOR THE DATA TYPE CLASS: If you do not have UML of class Account_yourLastName, you should do that first Basesd on the UML, provide the code of data type class Account_yourLastName to hold the information of an account with account number (String), name (String), balance (double), with no-argument constructor, parameter constructor Also, define some methods to handle the tasks: open account, check current balance, deposit, withdraw, and print monthly statement. At the end of each task we...
code in java please:)
Part I Various public transporation can be described as follows: A PublicTransportation class with the following: ticket price (double type) and mumber of stops (int type). A CityBus is a PublicTransportation that in addition has the following: an route number (long type), an begin operation year (int type), a line name (String type), and driver(smame (String type) -A Tram is a CityBus that in addition has the following: maximum speed (int type), which indicates the maximum...
CS 2050 – Programming Project # 1 Due Date: Session 3 (that is, in one week!). Can be resubmitted up to two times until Session 6 if your first version is submitted by session 3. In this project, you create two classes for tracking students. One class is the Student class that holds student data; the other is the GradeItem class that holds data about grades that students earned in various courses. Note: the next three projects build on this...
IT 210: Assignment 4 TASK1: Define and explain the following concepts with examples: Class Instance Encapsulation Abstraction Inheritence Polymorphism Multiple Inheritence You are allowed read books and materials from the Internet. Then answer to each of the above OOP related terminologies in your own words. Any indication of copying from any source will be seriously penalized as a case of plagiarism. TASK 2: (Programming Exercises from chap 11 (q3 pg.575)) Write a class named ‘Person’ with data attributes: name, address...
java In this project you will implement a trivia game. It will ask random trivia questions, evaluate their answers and keep score. The project will also have an administrative module that will allow for managing the question bank. Question bank management will include adding new questions, deleting questions and displaying all of the questions, answers and point values. 2. The project can be a GUI or a menu based command line program. 3. Project details 1. Create a class to...
java In this project you will implement a trivia game. It will ask random trivia questions, evaluate their answers and keep score. The project will also have an administrative module that will allow for managing the question bank. Question bank management will include adding new questions, deleting questions and displaying all of the questions, answers and point values. 2. The project can be a GUI or a menu based command line program. 3. Project details 1. Create a class to...