Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ its a 4 part question Background The HP-35 was the first scientific hand-held calculator, released in 1972 and an immediate success with engineers and

image text in transcribed

image text in transcribed

image text in transcribed

c++ its a 4 part question

Background The HP-35 was the first scientific hand-held calculator, released in 1972 and an immediate success with engineers and scientists. Amongst other features, it used an unusual way of entering numbers, called RPN. RPN (reverse Polish notation, named for Polish mathematician Jan Lukasiewicz) allows complex calculations to be entered without the use of parentheses. The key difference is that operators are entered after the operands, rather than between them The HP-35 implemented RPN using a stack of 4 registers, referred to as X, Y, Z, and T. The value in the X register is the one shown on the calculator's LED display; the other registers are used for temporary values during calculations. New values are entered into the X register, with existing values "pushed" up the register stack: the old value of X goes into Y, the old value of Y goes into Z, the old value of Z goes into T, and the old value of T is lost. Single-operand functions (such as square root) use and replace the value in the X register; other registers are unchanged. Functions that operate on 2 values (such as the arithmetic operators) use the values in Y and X, with the result going back into X. Values in the Z and T registers are "dropped" down the stack, with Z overwriting the old Y and T overwriting the old Z. The value of T is preserved, providing a simple way to do calculations with repeated values. This scheme allows calculations to be entered without using parentheses. For example, you could compute the compound expression (5+43 -2) like this SENTER 4 + 3 ENTER 2-7 Hints Youll need to define the class HPStack to represent the calculator's operand stack, with operations such as push (push all values up 1 level and store a value into X), pop (drop all values down 1 level and return the old X value), and peek (return the current X value). The simplest approach is to use an array to store the register values, with the methods manipulating the array elements The calculator should read and process tokens representing numbers and operator keys, with the current value of the X register displayed after processing each line. It should exit when all lines of input have been processed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Describe forward scheduling.

Answered: 1 week ago