Question
Write a function moronic calc() that takes a string consisting of a mathematical expression written in Moronic numerals, such as FFSSEI - FIIE, and returns
Write a function moronic calc() that takes a string consisting of a mathematical expression written in Moronic numerals, such as FFSSEI - FIIE, and returns the value of the expression in Moronic numerals. In the argument you may assume that there is always exactly one space after the first operand, followed by an operator, followed by a space, followed by the second operand. Negation of numbers is also allowed, but with some limitations mentioned below. If a number is negated, then the negation symbol appears immediately to the left of the leftmost numeral. Your calculator must support the following mathematical operators: Operation Symbol Example Addition + FIE + SSSEIII Subtraction SIE FSSSEIII Multiplication * FSFEIII / EIII Integer (Floor) Division / IIIII * EEEEEIII Exponentiation IIIII III Important notes: Either or both operands could be negative, except for the exponent in an exponentiation operation, which you may assume is positive. You may assume that the result of an operation is in the range [3071, 3071], with the exception of zero. If the result is positive, do NOT include a + sign in front of it. Finally, you will want to have the moronic calc() function call your arabic2moronic() and moronic2arabic() functions as needed to help solve this problem.
Examples: Function Call Return Value
moronic calc(FIE + SSSEIII) FSSSEEII
moronic calc(-SIE - -FSSSEIII) FSSIIII
moronic calc(-FSFEIII / EIII) -SEEEI
moronic calc(IIIII * EEEEEIII) SSSEEIE
moronic calc(-IIIII III) -SESIIIII
{"I": 1, "E": 8, "S": 64, "F": 512} {"IIE": 6, "IE": 7, "EES": 48, "ES": 56, "SSF": 384,"SF": 448}- these are the moronic numbers with their values
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