Question: The Laboratory Test 2 task is to write a program that takes one number from the OUSB Board DIP switches and a second number from

The Laboratory Test 2 task is to write a program that takes one number from the OUSB Board DIP switches and a second number from the command line arguments as input numbers to your program. The program will then perform a specific type of arithmetic operation, which will be determined by the value of the second command line argument (if it is provided). The resulting answer will then be displayed to the console screen in signed decimal representation. Additionally your program will be required to also represent the absolute value of the result as an 8-bit unsigned integer on the OUSB IO Board LEDs. Therefore if the arithmetic operation on the two input numbers results in a decimal result, the signed decimal value shall be displayed on the console screen and the absolute 8-bit integer representation (ie. truncated version) will be represented on the OUSB board LEDs. You will need to account for the limitations in the hardware and appropriately write the correct value to the OUSB board. The type of arithmetic operation that will be performed on the two input numbers will be determined by the second command line argument (if provided), where if the second argument is: 'a' an addition is to be performed, 's' a subtraction is to be performed, 'm' a multiplication is to be performed, 'd' a division is to be performed, and 'p' an exponential operation is to be performed. If only one argument is provided, then the two input numbers should added together. The functionality of this lab is relatively simple: + - / * ^ The emphasis in this lab is to achieve the basic FUNCTIONALITY REQUIREMENTS, however your program will also need to consider range checking, as well as basic, intermediate and advanced error level detection and handling to achieve full marks. You should aim for functionality first, and if time permits you should then attempt the error checking and implementing the basic, then intermediate and then the advanced error handling in priority order. 

The following text lists errors you must detect and a priority of testing. Note: order of testing is important as each test is slight more difficult than the previous test. E1. Error precedence: The order of errors can theoretically be check in any order, however if multiple errors occur during a program execution event, your program should only display one error code followed by a newline character and then exit (with a return 0). The displayed error codes to the console window should occur in this order: 'P' - Incorrect number of input command line arguments 'X' - Invalid numerical command line argument 'R' - command line argument out of range 'V' - Invalid operation selection 'M' - Division by zero 'Y' - MURPHY'S LAW (undefined error) Therefore if an invalid numerical command line argument and an invalid operation argument are passed to the program, the first error code should be displayed to the console, which in this case would be 'X'. Displaying 'V' or 'Y' would be result in a loss of marks. 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!