How a stack-based calculator works

Assignment Help Computer Engineering
Reference no: EM132174810

Using Python!!!!

You will be writing a stack-based calculator program. How a stack-based calculator works is as follows:

The user can input an integer or an operation. If an integer is entered, it is added to a stack (For this stack, we can use a simple list.) When an operation is entered, one of two things can happen:

IF this is the first time an operation has been given then pop the first two numbers given (i.e. pop from the top of the stack), and perform the operation with those two numbers, and store this result at the top of the stack.

Otherwise, perform the operation on the result of the last operation and the last entered integer. (i.e. pop the top two integers from the stack.)

As a hint, Python lists have a pop() method that returns the value from the top of the stack and push() that puts a value at the top of the stack.

The program will always be given valid input.

Note that many integers can be entered before an operation is given.

EXAMPLES:

out:

VALUE OR OPERATION:
in:

5
out:

LAST VALUE: 5 VALUE OR OPERATION:
in:

6
out:

LAST VALUE: 6 VALUE OR OPERATION:
in:

+
out:

LAST VALUE: 11 VALUE OR OPERATION:
in:

done
out:

EXITING

Reference no: EM132174810

Questions Cloud

What would be the additional funds needed : What would be the additional funds needed? Do not round intermediate calculations.
Write a program to assign passaengers seats in an airplane : Write a program to assign passaengers seats in an airplane. Assume a small airplane with seat numbering as follows.
Complete the ratio analysis table in the peer group : Complete the Ratio Analysis table in the Peer Group section of the financial portion of the business plan - Ration Comparison listing each full years results
Central tendencies within culture are known : Central tendencies within a culture are known as. All of the following are examples that enhance virtual team work, EXCEPT.
How a stack-based calculator works : Perform the operation on the result of the last operation and the last entered integer. (i.e. pop the top two integers from the stack.)
Comment on what this exercise reveals : Consider the case of two borrowers who are equally productive. Borrower 1 is considered to be "rich" as she has cash equivalent to A = $50 in her pocket.
Show that only the one with collateral can borrow : Assume that borrowers are not very poor, in that they have some collateral, but they are nevertheless suffering from financial exclusion.
What intellectual human resources management : What intellectual human resources management school of thought underlies your recommended changes?
Compute square roots of inputs until she presses the enter : Package Newton's method for approximating square roots in a function named newton.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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