Please write in c++ using queues, templates and interfaces We commonly write arithmetic expressions in the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Please write in c++ using queues, templates and interfaces We commonly write arithmetic expressions in the so-called infix form. That is, with each operator placed between its operand, as below: (5+6)*(4/3) Although we are comfortable writing expressions in this form, infix form has the disadvantage that parentheses must be used to indicate the order in which operators are to be evaluated. These parentheses, in turn, complicate the evaluation process. Evaluation is much easier if we can simply evaluate operators from left to right. Unfortunately, this evaluation will not work with the infix form of arithmetic expressions. However, it will work if the expression is in postfix form. In the postfix form of an arithmetic expression, each operator is placed immediately after its operands. The expression above is written in postfix form as 56+43/* Note that both forms place the numbers in the same order (reading from left to right). The order of the operators is different, however, because the operators in the postfix form are positioned in the order that they are evaluated. The resulting postfix expression is hard to read at first, but it is easy to evaluate programmatically. We will do so with stacks. Suppose you have an arithmetic expression in postfix form that consists of a sequence of single-digit, nonnegative integers and the four basic arithmetic operators (+,-.*./). This expression can be evaluated using the following algorithm in conjunction with a stack of floating-point numbers. Read the expression character-by-character. As each character is read in: If the character corresponds to a single-digit number (characters '0' to '9), then push the corresponding floating-point number onto the stack. If the character corresponds to one of the arithmetic operators (characters +, -, */), then Pop a number off of the stack. Call it operand1. Pop a number off of the stack. Call it operand 2. Combine these operands using the arithmetic operator, as follows Result = operand2 operator operand1 Push result onto the stack. When the end of the expression is reached, pop the remaining number off the stack. This number is the value of the expression. Applying this algorithm to the arithmetic expression 34+52/* Results 17.5 as expected. Requirements Create a program that reads the infix form of an arithmetic expression, evaluates it, outputs the postfix expression, and outputs the result. Assume that the expression consists of single-digit, nonnegative integers ('0' to '9") and the four basic arithmetic operators (+). Further, assume that the arithmetic expression is input from the keyboard with all the characters separated by white space on one line. Save your program in a file called postfix.cpp. Please define/explain each of the following: 1. Pseudocode / Flowcharts 2. Compilers vs. Interpreters 3. .class vs. java 4. Legal Identifiers in Java 5. Java Convention 6. Java Mathematical Operators (Addition, Subtraction, Multiplication, Division, Modulus) 7. Increment/Decrement Operators 8. String Methods 9. Concatenation 10. == vs. .equals() in Java 11. Variable Types 12. Loops Please write in c++ using queues, templates and interfaces We commonly write arithmetic expressions in the so-called infix form. That is, with each operator placed between its operand, as below: (5+6)*(4/3) Although we are comfortable writing expressions in this form, infix form has the disadvantage that parentheses must be used to indicate the order in which operators are to be evaluated. These parentheses, in turn, complicate the evaluation process. Evaluation is much easier if we can simply evaluate operators from left to right. Unfortunately, this evaluation will not work with the infix form of arithmetic expressions. However, it will work if the expression is in postfix form. In the postfix form of an arithmetic expression, each operator is placed immediately after its operands. The expression above is written in postfix form as 56+43/* Note that both forms place the numbers in the same order (reading from left to right). The order of the operators is different, however, because the operators in the postfix form are positioned in the order that they are evaluated. The resulting postfix expression is hard to read at first, but it is easy to evaluate programmatically. We will do so with stacks. Suppose you have an arithmetic expression in postfix form that consists of a sequence of single-digit, nonnegative integers and the four basic arithmetic operators (+,-.*./). This expression can be evaluated using the following algorithm in conjunction with a stack of floating-point numbers. Read the expression character-by-character. As each character is read in: If the character corresponds to a single-digit number (characters '0' to '9), then push the corresponding floating-point number onto the stack. If the character corresponds to one of the arithmetic operators (characters +, -, */), then Pop a number off of the stack. Call it operand1. Pop a number off of the stack. Call it operand 2. Combine these operands using the arithmetic operator, as follows Result = operand2 operator operand1 Push result onto the stack. When the end of the expression is reached, pop the remaining number off the stack. This number is the value of the expression. Applying this algorithm to the arithmetic expression 34+52/* Results 17.5 as expected. Requirements Create a program that reads the infix form of an arithmetic expression, evaluates it, outputs the postfix expression, and outputs the result. Assume that the expression consists of single-digit, nonnegative integers ('0' to '9") and the four basic arithmetic operators (+). Further, assume that the arithmetic expression is input from the keyboard with all the characters separated by white space on one line. Save your program in a file called postfix.cpp. Please write in c++ using queues, templates and interfaces We commonly write arithmetic expressions in the so-called infix form. That is, with each operator placed between its operand, as below: (5+6)*(4/3) Although we are comfortable writing expressions in this form, infix form has the disadvantage that parentheses must be used to indicate the order in which operators are to be evaluated. These parentheses, in turn, complicate the evaluation process. Evaluation is much easier if we can simply evaluate operators from left to right. Unfortunately, this evaluation will not work with the infix form of arithmetic expressions. However, it will work if the expression is in postfix form. In the postfix form of an arithmetic expression, each operator is placed immediately after its operands. The expression above is written in postfix form as 56+43/* Note that both forms place the numbers in the same order (reading from left to right). The order of the operators is different, however, because the operators in the postfix form are positioned in the order that they are evaluated. The resulting postfix expression is hard to read at first, but it is easy to evaluate programmatically. We will do so with stacks. Suppose you have an arithmetic expression in postfix form that consists of a sequence of single-digit, nonnegative integers and the four basic arithmetic operators (+,-.*./). This expression can be evaluated using the following algorithm in conjunction with a stack of floating-point numbers. Read the expression character-by-character. As each character is read in: If the character corresponds to a single-digit number (characters '0' to '9), then push the corresponding floating-point number onto the stack. If the character corresponds to one of the arithmetic operators (characters +, -, */), then Pop a number off of the stack. Call it operand1. Pop a number off of the stack. Call it operand 2. Combine these operands using the arithmetic operator, as follows Result = operand2 operator operand1 Push result onto the stack. When the end of the expression is reached, pop the remaining number off the stack. This number is the value of the expression. Applying this algorithm to the arithmetic expression 34+52/* Results 17.5 as expected. Requirements Create a program that reads the infix form of an arithmetic expression, evaluates it, outputs the postfix expression, and outputs the result. Assume that the expression consists of single-digit, nonnegative integers ('0' to '9") and the four basic arithmetic operators (+). Further, assume that the arithmetic expression is input from the keyboard with all the characters separated by white space on one line. Save your program in a file called postfix.cpp. Please define/explain each of the following: 1. Pseudocode / Flowcharts 2. Compilers vs. Interpreters 3. .class vs. java 4. Legal Identifiers in Java 5. Java Convention 6. Java Mathematical Operators (Addition, Subtraction, Multiplication, Division, Modulus) 7. Increment/Decrement Operators 8. String Methods 9. Concatenation 10. == vs. .equals() in Java 11. Variable Types 12. Loops Please define/explain each of the following: 1. Pseudocode / Flowcharts 2. Compilers vs. Interpreters 3. .class vs. java 4. Legal Identifiers in Java 5. Java Convention 6. Java Mathematical Operators (Addition, Subtraction, Multiplication, Division, Modulus) 7. Increment/Decrement Operators 8. String Methods 9. Concatenation 10. == vs. .equals() in Java 11. Variable Types 12. Loops
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
ABC Company acquired 60,000 shares of DEF Incorporated's 200,000 ordinary shares on January 2, 2019 for P 4,000,000 when the net assets of DEF Incorporated was P 12,000,000. The excess of acquisition...
-
Economists estimate price elasticities more precisely by using average price and quantity to compute percentage changes. Thus, Using this formula, compute E for a popcorn price increase from 15 cents...
-
Suppose that the motion of a spring is given by d(t) = 6e -0.8t cos (6t) + 4, where d is the distance, in inches, of a weight from the point at which the spring is attached to a ceiling, after t...
-
The agreement contained a liquidated damages clause that held, Should Employee voluntarily terminate or the Employer terminates his/her employment within one year of executing this Agreement,...
-
On December 1, 2014, Prosen Distributing Company had the following account balances. During December, the company completed the following summary transactions. Dec. 6 Paid $1,600 for salaries and...
-
A manufacturing company reports the following information. Raw materials inventory, ending Raw materials used Current Year $ 169,500 2,160,000 1 Year Ago 2 Years Ago $ 190,500 2,522,000 $ 197,500...
-
Bhavika Investments, a group of financial advisors and retirement planners, has been requested to provide advice on how to invest $200,000 for one of its clients. The client has stipulated that the...
-
You just inherited $100,000. You are investing this money for two years at 0.6% compounding monthly interest rate in whole dollars. How much money will you have at the end of the two years?
-
When the Federal Reserve Bank is aggressively buying huge amounts of U.S. government bonds, offering great low-cost deals on Repos to all U.S. banks, and if they are increasing the amount of...
-
Consider a force of 5N[NW], then a force of 5N [SW]. Determine the equilibrant of the resultant of the forces? Draw a diagram showing the resultant and the equilibrant. Show your work
-
A Field Poll Survey reported that 66% of registered voters in a state approved of allowing two people of the same gender to marry and have regular marriage laws apply to them. Among 18 to 39 year...
-
National Shops, Incorporated reported the following amounts on its balance sheet as of December 31, 2022: Inventory $ 325,000 Notes payable 100,000 Cash 150,000 Common stock 750,000 Net property,...
-
What fundamental components characterize team dynamics, and how do these dynamics substantively influence the collective efficacy and productivity of the team?
-
Create a new product-oriented mission statement for Facebook. In your opinion, the product-oriented mission statement is better than a market-oriented mission statement? Justify
-
From 1970 to 1990, Sri Lanka's population grew by approximately 2.2 million persons every five years. The population in 1970 was 12.2 million people.What is the best formula for P, Sri Lanka's...
-
Rebecca and Walter Bunge have been married for 5 years. They live at 883 Scrub Brush Street, Apt. 52B, Las Vegas, NV 89125. Rebecca is a homemaker and Walt is a high school teacher. Rebecca's Social...
-
Dr. George E. Beeper is a single taxpayer. He lives at 45 Mountain View Dr., Apt. 321, Spokane, WA 99210. Dr. Beeper's Social Security number is 775-88-9531. Dr. Beeper works for the Pine Medical...
-
Indicate, in each of the following situations, the number of exemptions the taxpayers are entitled to claim on their 2012 income tax returns. Number of Exemptions a. Donna, a 20-year-old single...
-
What is the current status of the Sarbanes-Oxley Act? What do executives think of it now? What impact has it had?
-
Hannah Toberman had enjoyed her engineering job at Allstar Electronics, but she was beginning to grow restless. Most of her work for the past 5 years had involved designing minor adjustments to...
-
Most entrepreneurs use their own savings or borrow from family and friends to launch a start-up. How much capital could you possibly raise?
Study smarter with the SolutionInn App