Question
Task: Write a Little Man Computer program that converts a given Little Man number into a number using the base-10 number system. The Little Man
Task: Write a Little Man Computer program that converts a given Little Man number into a number using the base-10 number system.
The Little Man number system is similar to the Roman number system; however, it has some exceptions and limitations. You must display the result as an output before halting the program. For example, the LMC number CXI is 111, and XXXVI is 36.
Roman numeral | Natural number |
---|---|
I | 1 |
V | 5 |
X | 10 |
L | 50 |
C | 100 |
D | 500 |
Your program will only be able to calculate a natural number up to and including 999. If the user enters a Little Man numeral that exceeds this, the output is to be 999. Six input values are provided by the user and the order of input is important:
-The first input is the number of Ds that the Little Man numeral contains.
-The second input is the number of Cs that the Little Man numeral contains.
-The last input is the number of Is that the Little Man numeral contains. For example, if the user provides the inputs 0, 0, 0, 1, 2, 2, then this will be the equivalent of XVVII.
1.1. Write a pseudocode to describe your algorithm to solve the task:
-Describe the algorithm using natural language, structured using the convention of normal programming language.
-When necessary, use looping and conditional constructs.
-Name the symbols (variables) sensibly to make their use clear.
1.2. Draft a test plan to be used as a verification method to ensure that your LMC program is correct:
-Tabularise test input value(s) and the expected output(s).
-Consider uncommon cases, such as when the calculator reaches its maximum value, when negative values are calculated, or when an input provided is unexpectedly large.
Hint: an example test plan is provided for your reference.
Input value(s) | Expected output value(s) | Notes |
---|---|---|
2, 4, 6 | 10 | All even numbers |
1, 3, 5 | 9 | All odd numbers |
1.3. Implement an LMC program according to the algorithm you designed in 1.1. Use the test suite you designed in 1.2 to verify that the implementation of your algorithm is correct.
-Use symbolic addressing only, numerical addressing will be disabled.
Your LMC program:
-must request the correct number of input(s)
-must produce the correct number of output(s)
-must produce the correct output value(s) for all given test cases.
Ensure that your code is tidy (spacing, indentation) and that you include comments to describe the algorithm.
Hint: The HLT command must be executed. Make sure to check that it is not missing or that you do not have syntax or run-time errors.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started