Please write a program that can evaluate an infix arithmetic expressions involving doubles combined with +,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Please write a program that can evaluate an infix arithmetic expressions involving doubles combined with +, -, *, /, and ^ operators as well as parenthesis. The parenthesis does NOT have to be fully balanced. For example:( 2 * 3^2). The fully parenthesized version of this expression would be (2* (3^2)) However, make sure that: Each such expression always has one opening parenthesis and one closing parenthesis. For example, you need to represent as (2+3) not 2 + 3. *Numbers and operators including parenthesis are all separated by a space. Please do not first convert the infix expression into postfix, and then evaluate the postfix. Hints: You need to have two stacks for this problem.One stack is to hold all operators, and the other is to hold numbers. Here shows a working algorithm for you reference: Problem 6: Simple Calculator Write a program prompts the user to enter two integer values and the symbol of an arithmetical operator (+,-, *, /, %). The program then uses the switch statement to print the result of arithmetical operation, otherwise the program displays the message "Invalid symbol". Sample input/ output: Enter tuo integers: 59 Enter the symbol of an arithmetical operator (+,-, , , x): + 5 9 14 Enter tuo integers: 59 Enter the symbol of an arithmetical operator (+, -, 59 Invalid symbol!!! /. x): ^ C++ Please write a program that can evaluate an infix arithmetic expressions involving doubles combined with +, -, *, /, and ^ operators as well as parenthesis. The parenthesis does NOT have to be fully balanced. For example:( 2 * 3^2). The fully parenthesized version of this expression would be (2* (3^2)) However, make sure that: Each such expression always has one opening parenthesis and one closing parenthesis. For example, you need to represent as (2+3) not 2 + 3. *Numbers and operators including parenthesis are all separated by a space. Please do not first convert the infix expression into postfix, and then evaluate the postfix. Hints: You need to have two stacks for this problem.One stack is to hold all operators, and the other is to hold numbers. Here shows a working algorithm for you reference: Problem 6: Simple Calculator Write a program prompts the user to enter two integer values and the symbol of an arithmetical operator (+,-, *, /, %). The program then uses the switch statement to print the result of arithmetical operation, otherwise the program displays the message "Invalid symbol". Sample input/ output: Enter tuo integers: 59 Enter the symbol of an arithmetical operator (+,-, , , x): + 5 9 14 Enter tuo integers: 59 Enter the symbol of an arithmetical operator (+, -, 59 Invalid symbol!!! /. x): ^ C++
Expert Answer:
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date:
Students also viewed these computer network questions
-
Find (4.2 + 4x + 6x) dx + C
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Melissa buys an iPod for $120 and gets consumer surplus of $80. a. What is her willingness to pay? b. If she had bought the iPod on sale for $90, what would her consumer surplus have been? c. If the...
-
A square loop of wire consisting of a single turn is perpendicular to a uniform magnetic field. The square loop is then re-formed into a circular loop, which also consists of a single turn and is...
-
You and your snowboard, with a combined mass of \(70 \mathrm{~kg}\), ride a half-pipe that has a radius of \(5.0 \mathrm{~m}\). As you pass the bottom, you create a pressure of \(27 \mathrm{kN} /...
-
Explain why governance reporting regulations and principles were introduced.
-
The following facts pertain to a non-cancelable lease agreement between Faldo Leasing Company and Vance Company, a lessee. The lessee assumes responsibility for all executory costs, which are...
-
61. The solubility product of CuS, AgS and HgS are 10 37, 104 and 1054 respectively. The solubility of these sulphides will be in the order (1) HgS> AgS > Cus (2) AgS>HgS > CuS (3) CuS AgS > HgS (4)...
-
Consider the two mutually exclusive projects in Table P5.49. Salvage values represent the net proceeds (after tax) from disposal of the assets if they are sold at the end of each year. Both projects...
-
The Yufi mining corporate is set to open a gold mine in mansa. According to the evaluation made this this far, the mine will cost k900,000 to open and have an economic life of 11 years .it will...
-
In plants inbreeding may occur naturally in the form of self- pollination. Inbreeding is also deliberately practiced as a method to create genetic unifor- mity in populations of interest for genetic...
-
Research the United States Office of Personnel Management (OPM) incident announced in July 2015. Summarize the key aspects of the case and what key/critical pieces of data were found. Then using that...
-
Spacey, a lithium battery manufacturer, produces two kinds of batteries. It uses the same raw material to manufacture those batteries, called RW. Each unit of RW can be used to make 4 units of the...
-
External media regulation in South Africa Write a critical discussion in which you explain how freedom of expression, democracy and the media intersect. Your discussion should give a brief discussion...
-
Given that (4) = 0.15, calculate (Da) 601 at the annual effective rate. (Da) 601-
-
Utility from clean air (public good) is us(A) = 55A A^2 and Leo's utility from clean air is ul(A) = 45A2A^2. A is the amount of clean air in their apartment. In order to clean up the air in their...
-
The production budget of Artest Company calls for 80,000 units to be produced. If it takes 30 minutes to make one unit and the direct labor rate is $16 per hour, what is the total budgeted direct...
-
Defined a two-dimensional array of grades with 10 rows and three columns, representing 10 students grades on three exams. Use a stream pipeline to calculate the average of all the grades. For this...
-
Write an application that calculates the average of a series of integers that are passed to method average using a variable-length argument list. Test your method with several calls, each with a...
-
A palindrome is a word that reads the same both forward and backward, such as radarand madam. Write an application to check if a string entered by the user is a palindrome or not.
-
Number of cars crossing the Golden Gate Bridge each hour. State whether the data described are discrete or continuous and explain why?
-
Number of stars in each galaxy in the universe. State whether the data described are discrete or continuous and explain why?
-
The times required by students to complete a statistics test. State whether the data described are discrete or continuous and explain why?
Study smarter with the SolutionInn App