Write client program that uses the stack abstract data type

Assignment Help Computer Engineering
Reference no: EM131858735

Problem

Write a client program that uses the Stack abstract data type to compile a simple arithmetic expression without parentheses. For example, the expression

a + b * c - d

should be compiled according to the following table

Operator

Operand1

Operand2

Result

*

B

C

Z

+

A

Z

Y

-

Y

D

x

The table shows the order in which the operations are performed (*, +, -) and operands for each operator. The result column gives the name of an identifier (working backward from z) chosen to hold each result. Assume that the operands are the letters a through m and the operators are (+, -, *, /). Your program should read each character and process it as follows: If the character is blank, ignore it. If the character is neither blank nor an operand nor an operator, display an error message and terminate the program. If it is an operand, push it onto the operand stack. If it is an operator, compare its precedence to that of the operator on top of the operator stack. If the current operator has higher precedence than the one currently on top of the stack (or if the stack is empty), it should be pushed onto the operator stack. If the current operator has the same or lower precedence, the operator on top of the operator stack must be evaluated next. This is done by popping that operator off the operator stack along with a pair of operands from the operand stack and writing a new line in the output table. The character selected to hold the result should then be pushed onto the operand stack. Next, the current operator should be compared to the new top of the operator stack. Continue to generate output lines until the top of the operator stack has lower precedence than the current operator or until it is empty. At this point, push the current operator onto the top of the stack and examine the next character in the data string. When the end of the string is reached, pop any remaining operator along with its operand pair just described. Remember to push the result character onto the operand stack after each table line is generated.

Reference no: EM131858735

Questions Cloud

Differences between top-down and bottom-up accountability : The criminal justice worker is accountable to whom and why? Discuss the differences between top-down and bottom-up accountability.
Future of digital crimes and digital terrorism : In the United States, a number of law enforcement agencies, including the Secret Service, the Federal Bureau of Investigation
What a forecasting system must do : Considering what a forecasting system must do, select a characteristc of a system (accuracy, cost, flexibility, etc.) and discuss its importance.
Provide a description of an enterprise system : Provide a clear description of an enterprise system and describe how it works.Discuss three ways an enterprise system can provide value for a company.
Write client program that uses the stack abstract data type : Write a client program that uses the Stack abstract data type to compile a simple arithmetic expression without parentheses. For example, the expression
Describe philosophy as a domestic violence advocate : Describe philosophy as a domestic violence advocate, how it developed, and why it would be appealing.
Problem on automobile insurance : Consider an insurance company that wants to underwrite automobile insurance; the actuaries need historical data involving claims and motor vehicle violations.
Identify three possible dissertation research topics : Identify three possible dissertation research topics related to the subject of this course.
Public educators regarding terrorist threats : Are the media the most effective risk, warning, and crisis communicators and public educators regarding terrorist threats

Reviews

Write a Review

Computer Engineering Questions & Answers

  Calculate matrix-vector product using mpi processes

Implement a parallel algorithm that calculates matrix-vector product using MPI processes, What is the cause of the difference? What are the advantages and disadvantages of two approaches?

  What is the importance of having ram

What is the importance of having enough RAM? How does it relate to how quick a computer can process data from a large database residing on ones hard drive? What is the importance of virtual memory if you don't have too much RAM & how does it relate..

  How are responses to an rfp evaluated

What is a request for proposal (RFP)? How are responses to an RFP evaluated? Determine hardware and system software requirements for application software.

  How the fact-finding techniques will be used

With this task in mind, create a slide presentation that describes each fact-finding technique and how the fact-finding techniques will be used throughout the development of the database system.

  Question1 a multiprogramming operating system uses an

question1. a multiprogramming operating system uses an apportioning method and divides the 60 mb of existing memory

  Write down a 2-3 page paper that answers the questions

write a 2-3 page paper that answers the questions below. be prepared to fully support your answers. explain in your own

  How company x is going to expand its information system

Develop a list of actions you might conceivably take if no agreement is reached.

  What would that information tell about your network health

Consider an ARP poisoning attack. What information would you expect to be collected in an auditing tool

  Where qualitative and quantitative requirements can defined

It is claimed that in respect to subjects where qualitative and quantitative requirements can be defined, the quantitative alternatives should be preferred

  How long it will take for heater to reach steady operation

An electric resistance space heater is designed such that it resembles a rectangular box 50 cm high, 80 cm long, and 15 cm wide filled with 45 kg of oil.

  Write a class called course that represents a course

Write a class called Course that represents a course offered to students. It should contain instance data that represents the course title, course code.

  Develop guidelines for professional responsibilities

Continuing with the scenario from Week 5, develop guidelines for professional responsibilities in an organization related to identifying and resolving ethical issues in IT.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd