CODED IN C. NOT C++. ONLY C
Multi-Number System Calculator In Part 2 of this assignment, youwill augment your previous implementation for first. Rather thanhave all binary integers, the integers can be in hexadecimal,octal, base 10, or binary. All input sequences will remain 4 bitpatterns. Thus, this will only effect the Delimiter and Numberinput sequences. We also remove the NaN input sequence and replaceit with the Parenthesis input sequence. Let us now redefine theseinput sequences: • 0001 Delimiter: This input sequence denotes theend of the current equation and the start of a new equation. Thesequence will be followed by a 2 character pattern signifying whatnumber system is to be used [”0x” for hexadecimal, ”0h” for octal”,”00” for base ten, and ”0b” for binary”]. Upon receiving thisinput, the program should print the result of the previous equationin the given number system. The result should be preceeded by thesymbol designating the base being used. An equation will always endwith a delimiter. • 0010 Number: This input sequence denotes thatthe following sequence is a number x. This input sequence will befollowed by a 4 character sequence represting a number. This numberwill signify the amount of binary digits that the number x iscomprised of. The 4 character number will be preceeded by a 2character pattern signifying what number system is being used.[”0x” for hexadecimal, ”0h” for octal”, ”00” for base ten, and ”0b”for binary”]. The 4 bit number will be followed by another 2character pattern once again signifying the number system beingused for the number x. Lastly, the characters for the number x willfollow. • 1010 Open Parenthesis: This input sequence denotes thebeginning of a ”sub equation” or an equation enclosed inparenthesis. It will always be followed, at some point, by a closedparenthesis. The ”sub equation” enclosed within the sub parenthesisshould be resolved in its entirety before interacting with theremaining equation on the outside of the parenthesis. A set ofparenthesis may exist within another pair of parenthesis. • 1001Closed Parenthesis: This input sequence denotes the end of a ”subequation” or the end of an equation enclosed in parenthesis. Itwill always be preceded, at some point, by a closed parenthesis.The ”sub equation” enclosed within the parenthesis should beresolved before the remaining equation on the outside of theparenthesis. There will always be at least one value inbetween anopen and closed parenthesis. Input format: This program takes onesequence from the command line. The sequence will be a binarysequence. The sequence should then be read using the previous rulesin order to determine the underlying equation(s). Output format:Your program should output the result of each of the equations inthe designated base. Each equation will result in some output. Theoutput will be either a numeric solution to the equation or thevalue ”NaN”. The solution to each equation should be printed on adifferent line. Example Execution: Some sample runs and resultsare: 3 test 1: $./second001000000000010xA01000000100h000000100h5000010x 0x32 test 2:$./second 00100b01000b100001001000100b00100xAA000100 001360 Tobreak down each of the examples: test 1: 0010 00 0001 0x A 0100 001010 0010 0b 11 00111 0100 10 0010 0b0010 0h50 1001 00010x can beinterpreted as: [Number, base 10-1 digit long, hexidecimal A,Symbol, addition, Open parenthesis, Number, binary-3 digit long,base 10-111, Symbol, multiplication, Number, binary-2 digits long,octal 50, End parenthesis, Delimiter-hexadecimal] or 0xA + (111 *0h50) which is: 10 + (111 * 40) = 4450 test 2: 0010 0b0100 0b10000100 10 0010 0b0010 0xAA 000100 can be interpreted as: [Number,binary-4 digits long, binary 1000, Symbol, multiplication, Number,binary-2 digit long, hexidecimal AA, Delimiter-base 10] or 0b1000 *0xAA which is: 8*170= 1360
CODED IN C. NOT C++. ONLY C Multi-Number System Calculator In Part 2 of this assignment, you will augment your previous
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
CODED IN C. NOT C++. ONLY C Multi-Number System Calculator In Part 2 of this assignment, you will augment your previous
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!