The part after this line is the assignment, I\'ve completed a portion of it but
ID: 3759673 • Letter: T
Question
The part after this line is the assignment, I've completed a portion of it but need help with a part of it, at the end of this post is what I need help on specifically. I'm stuck :/
-------------------------------------------------------------------------------------------
The purpose of this program is to learn to use stacks. You will be given 2 Roman Numbers with an operator separating them. The operator will be either a minus, plus, or multiply sign. You need to convert the 2 Roman Numbers to Arabic Numbers (the kind we use), perform the operation and then display the result as a Roman Number. If either Roman numeral is invalid, print an error message to the user.
Roman Numbers have these rules: 1) The values of Roman Numerals are as follows: a. I = 1 b. V = 5 c. X = 10 d. L = 50 e. C = 100 f. D = 500 g. M = 1000 2) The value of the Roman Number will be the total of the individual numerals according to these rules: a. If the current numeral is less than or equal to the previous numeral, then the value of the previous numeral is added to the total. b. If the current numeral is greater than the previous numeral, then the previous numeral is subtracted from the current numeral and that result is added to the total.
When you write your Roman Number as output, keep these rules in mind: 1) Only Roman Numerals that are powers of 10 may be repeated. Example: II is valid, XX is valid, VV is not valid, DD is not valid. 2) No more than 3 of the same Roman Numerals may be repeated in sequence. Example: III is valid, IIII is not valid. 3) A smaller Roman Numeral may appear immediately to the left of a larger Roman Numeral only if the value of the smaller is less than or equal to 10 times the value of the larger. Example: IV is valid, IX is valid, IL is not valid, CD is valid, XD is not valid. 4) Only Roman Numbers that are powers of 10 may appear immediately in front of a larger Numeral (for subtraction purposes). Example: IX is valid, IV is valid, VX is not valid, LC is not valid, XC is valid.
When you read the Roman Number as input, you will need to push each item on a stack as you read it since you don’t know what to do with it until you read the next item. You should apply the above rules to create an algorithm to convert a Roman Number to an Arabic number.
After you have converted the 2 Roman Numbers to Arabic numbers and performed the operation, you will need to convert the Arabic number into a Roman Number. You should convert each Arabic numeral to the appropriate Roman Number equivalent and print the resulting Roman Number.
Here are some examples for some numbers: XVII to represent 17, MCMLIII for 1953, and MMMCCCIII for 3303. In this assigment, we will input Roman Numbers in such a way that the result of the expression is 3999, which is MMMCMXCIX, or less.
User-friendliness is one of the software quality, please make sure your program is user-friendly.
You are required to code your own stack and queue. If you use Java Generics, there will be a deduction of 10% each.
-------------------------------------------------------------------------------------------
So this is the assignment given to us and so far I have created my own stack and queue but my question is how would I implement these two classes into my main?
I've seen other questions where people have answered it in a string method in one java file.
So basically what I need help with is creating the main class for this program. My STACK class is CharacterStack.java and my QUEUE class is CharacterQueue.java, how would I utilize these two in my main which I happened to name CalculateRomanNumerals.java
Explanation / Answer
Hi,
Below is the solution to your question:
I am explaining the 4th bulletain little more in brief:
Okay i will try to explain it with an example.
Hope this is what you are looking for...HAPPY ANSWERING!!!!!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.