Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a script that enables the user to enter mathematical word problems like Add two and three and Divide nine by three, then use
Write a script that enables the user to enter mathematical word problems like "Add two and three" and "Divide nine by three", then use string processing to break apart the string into the numbers and the operation and return the result. So "Add two and three" would return 5 and "Divide nine by three" would return 3. The user should enter only the words in lower case for the numbers 0 through 9 and specify the four mathematical operation in the following syntax: Add X and Y . Subtract X from Y Multiply X by Y Divide X by Y Please think about what data structure should be used to convert a numeral word to its correponding number. Please print an warning message, "Invalid Input", for the following exceptions in the input: Numbers outside the range of 0 to 9 Operations not in the specified syntax Division by zero Some examples are provided below: Please enter a math question: Multiply ten by two Invalid input! Please enter a math question: Multiply nine by two The answer is 18 Please enter a math question: Divide six by zero Invalid input! Please enter a math question: Divide six by three The answer is 2. Please enter a math question: Deduct three from five Invalid input! kernell Lidia
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