Write a script that enables the user to enter mathematical word problems like Add two and...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Related Book For
Introduction To Java Programming And Data Structures Comprehensive Version
ISBN: 9780136520238
12th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these algorithms questions
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
Provide the appropriate statute for your answer (format style - IRAC - Issue, Rule, Application and Conclusion.) what are your thought? Problem Scenario- Earnest is married to Janice. Earnest and...
-
Do those who protest against globalization make any valid point(s) that all people, whether for or against globalization, should consider?
-
If the odds of an event occurring are 5: 8, what is the probability that the event will occur?
-
Consider the sample space and the partition Let be the field generated by this partition, and define the mapping as follows: This seemingly innocent mapping is not a random variable with respect to...
-
Linda Kipp started a business on May 1, 20--. Analyze the following transactions for the first month of business using T accounts. Label each T account with the title of the account affected and then...
-
Under the CERT program, if a request for medical records is sent to the provider, how long will they allow submission of the requested information?
-
Reconsider Problem 9.3. Suppose now that the demand at each of the destinations has been reduced by 10, so that the new demands are 20, 30, and 20 at destinations 1, 2, and 3, respectively. Introduce...
-
Consider the decisions of a representative consumer whose preferences are given by u(C, 1) = aC + Blog l, in which C is the quantity of consumption and I is the quantity of leisure. The parameters a...
-
Ohio residents who live in one municipality and work in another may be able to claim a credit for taxes paid on their resident municipal income tax return. What is the total credit for taxes paid to...
-
1.How should the VIP Industries get out of the bind that it findsitself in? Outline the contours of the marketing plans and policies that VIP needs to formulate and implement? 2. Analyse the problems...
-
The range rate of a satellite that is in an elliptical orbit with respect to a central body can be determined by r = r (2.1) where (r) is the satellite's range rate, (r) is the satellite's range with...
-
What "stock" stories do you recall hearing when you attended school? (For example, I grew up learning that Christopher Columbus was a hero. However, later in my life, I realized what I had learned...
-
1.Sales were $100,000 two months ago and increased by 20% last month. How much were sales last month?1 4 Sales were $120,000 last month and decreased by 20% this month. How much were sales this...
-
Discussion : 1 Discuss the effect of the density of material on the power intensity of laser source. 2 Discuss the relation between the absorption coefficient and intensity of light. 3- The light...
-
3.16. For a system with non-identical service rates (see Sect. 3.5) and a limit of N jobs in the system (Eq. 3.13), obtain an expression for the mean service time per job, E[Ts], as a function of the...
-
Suppose the text file on the Web http://liveexample.pearsoncmg.com/data/Scores.txt contains an unspecified number of scores separated by spaces. Write a program that reads the scores from the file...
-
Define a new class named UnweightedGraphWithGetPath that extends UnweightedGraph with a new method for finding a path between two vertices with the following header: public List getPath(int u, int...
-
Implement the following method that returns the maximum element in an array: public static > E max(E[] list) Write a test program that prompts the user to enter 10 integers, invokes this method to...
-
If we roll a die, the obvious sample space is . If we can observe and are interested in the exact outcome, then we may consider singleton events consisting of a single outcome, The natural...
-
Consider the sample space and the partition Let be the field generated by this partition, and define the mapping as follows: This seemingly innocent mapping is not a random variable with respect to...
-
Given , consider the family of subsets This is not a field, since, for instance, . = {1,2,3,4}
Study smarter with the SolutionInn App