Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions

Question

1. How does Kiwi Experience maintain a continual customer focus?

Answered: 1 week ago