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
-
The number of chocolate chips in an 18-ounce bag of Chips Ahoy! chocolate chip cookies is approximately normally distributed, with a mean standard deviation of 118 chips, according to a study by...
-
1.what is value engineering ?2.what is value engineering importance ?3.what is the aim value of engineering ?4.what are the five 5 key principles of value engineering ?5.immediate benefits of value...
-
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...
-
Prove that if K is a positive semi-definite matrix, and f rng K. then the quadratic function p(x) = xT K x - 2xT f + c has no minimum value.
-
Standard Boxes Sustainable Deluxe Boxes Total Quantity Selling price per unit 108.00 18.00 126.00 $ 18.80 $ 23.00 $ 41.80 Revenue $ 2,030.40 $ 414.00 $ 2,444.40 Subtract: Variable Costs $ 1,080.00 $...
-
On a Sunday afternoon in 2005 at a busy hospital in the Pacific Northwest, computers started running slower and documents would not print. By Monday morning, the situation became worse as more...
-
Here is a list of words or phrases related to computerized accounting systems. 1. Entry-level software. 2. Enterprise resource planning systems. 3. Network-compatible. 4. Audit trail. 5. Internal...
-
A Company manufactures organic baked whole grain energy snack, made with a blend of carbohydrates, fiber, protein and fat to give kids energy so they can keep zipping and zooming along. Their...
-
Al is an employee at Spatula City, a retail store that sells only spatulas. One day Al sees a customer, George, come into the store wearing sunglasses, and a large coat with many pockets. George is...
-
prepare selling and administrative expenses budget of second quarter when the direct labour of April, may and June are 27625, 28875, and 30375 respectively. Labour requires 15 minutes per unit for...
-
Can you elucidate the nuanced interplay between diversity, equity, and inclusion initiatives and their impact on employee engagement, retention, and organizational performance?
-
You have opened an account with a local broker & you placed an order for 4,000.0 shares of KLM corp. @ $8.0 a share. The initial margin is 50.0%; the broker's rate is 6.0% and the maintenance margin...
-
How I Communicate ? Think about your day yesterday. List 10 people with whom you communicated and what type of communication was established. The communication may be verbal, non-verbal, written,...
-
A chemical reaction can absorb or release energy, forming endothermic or exothermic reaction. Explain why a chemical reaction becomes exothermic or endothermic in nature using suitable examples.
-
HappyRetirement fund owns 100000 shares of stock A, 200000 shares of stock B, and 300000 shares of stock C. The closing prices of the three stock were 25, 30, and 35, respectively. If the fund has...
-
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...
-
Sanchez Consulting applies overhead to consulting projects based on the direct labor hours charged by employees to each job. Selected data for the firm follow: What is the amount of over- or...
-
Given the following data for Scurry Company, what is the cost of goods sold? a. $500,000. c. $800,000. b. $600,000. d. $950,000. Beginning inventory of finished goods Cost of goods manufactured...
-
Boston Furniture Company manufactures several steel products. It has three production departments: Fabricating, Assembly, and Finishing. The service departments include Maintenance, Material...
Study smarter with the SolutionInn App