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

  Questionalgorithm secreta0n - 1input an array a0n - 1 of n

questionalgorithm secreta0..n - 1input an array a0..n - 1 of n real numbersminval larr a0 maxval larr a0for i larr 1 to

  Security awareness programs for the organization

Security architecture, and which controls you elect to put in place, should be risk-based and driven by business needs, expressed in policy.

  How to use jump statements in register

Assume for each part of this problem that the EAX register contains 00 00 00 4F and the doubleword referenced by value contains FF FF FF 38. Determine whether each of the conditional jump statements causes a jump to dest. #1 cmp eax, 04fh je dest ..

  Questionthe most important public consulting firm has been

questionthe most important public consulting firm has been tasked with implementing an online patient care system that

  Determine the angle of twist at b and c

For the shaft in Problem. replace the torque at C by two equal torques of 1500 lb-in at B and C. Compute the angle of twist at B and C and the torsional.

  Calculate the convolution of the three different images

Consider the area of the nonzero middle region to be 2*2, 10*10 and 20*20 for the three images.

  What are the pros of home networking

Do you find that most of the files are in real stored on a single computer or to you actually have a server configuration in your home with common files?

  Write a program that draws two solid squares

Write a program that draws two solid squares: one in pink and one in purple. Use a standard color for one of them and a custom color for the other.

  Construct source programing to budget in monthly income

Construct source programing to budget $5,000 in monthly income so that all monies are expensed and accounted for.

  How to create a class that player guess anumber

make a class that player guess anumber, the application generates a random number, and player determine whether they are correct. Display a message indicating whether the players guess was correct, too high or too low.

  Define difference between a shallow copy and a deep copy

Overload the operator += for the class newString to perform the following string concatenation; suppose that s1 is "Hello" and s2 it "there". Then the statement s1 += s2; should assign "Hello there" to s1, where s1 and s2 are newString objects.

  Make a c++ class that implements a "safe" array

design a C++ class that implements a "safe" array, where the arrays bounds are checked before accessing its elements. The class constructor must accept an integer parameter and create a dynamic array of that size for storing integers, implemented ..

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