I have this assignment where I have to create a program that simulates a simple calculator (two operands, one operator: +, -, /, *, etc.)...
I have the math part covered, but I've got a few doubts about one other aspect of the coding:
The "calculator" must have four modes: Hex, decimal, octal and binary...
The user inputs the values according to the selected mode, they are then evaluated (to see if they fit within the selected mode) and the program goes on to perform the selected operation. Finally, it inputs the result in the selected mode...
0101 + 0001 = (values match bin. mode) Result: 0110
07 + 08 = (second value does not match) Result: "Input Error" Message
Is this algorithm correct?:
1. Receive values (strings)
2. Convert strings to decimal values and perform operations
3. Convert decimal values (results) to string according to selected mode
4. Output resulting value (string)
If this is correct, I may need some help with converting strings to decimal and viceversa...
Thanks in advance!