For this project, you will develop a Java program that will act as an RPN reverse polish notation calculator
INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS
PRELIMINARIES:
You need to learn about top-down design and Stacks to do this assignment properly.
THE ASSIGNMENT:
For this project, you will develop a Java program that will act as an RPN (reverse polish notation) calculator. To do this, you will have to use the stack class (stack of integers), together with a driver program which can handle the operations:
- + add the top two items
- * multiply the top two items
- - subtract the top item from the next item
- / integer divide the second item by the top item
- % find the integer remainder when dividing the second item by the top item
- m unary minus -- negate the top item
- r exchange the top two items
- d duplicate top item on stack
- p print (to the screen) the top item
- n print and remove the top item
- f print all the contents of the stack (leaving it intact)
- c clear the stack
- q quit
- h (or ?) print a help message
There is a (similar) standard RPN calculator called 'dc' (desk calculator) on almost all UNIX systems.
INPUT:
Your program will have keyboard input from the user of the program.
Example: (note: @ stands for typing a return)
h @
p print top
n print top and remove
d duplicate top
r exchange top two items
f print contents of stack
c clear stack
+ add
- subtract
* multiply
/ integer divide
% integer remainder
m unary minus
q quit
h,? this help
33 44 p @
44
f @
33 44 #
r f @
44 33 #
r @
n @
44
d @
f @
33 33 #
+ p @
66
21 * p @
1386
11 + p @
1397
17 / p @
82
8 % p @
2
m p @
-2
f @
-2 #
c @
f @
#
q @
OUTPUT:
The program must write all its output to standard output (the default standard output is the screen).
WHAT TO TURN IN:
You will turn in two e-mail messages. Please follow these rules:
- Always send me e-mail as plain text in the main message body.
- Attach any Project files.
- Always use the exact subject line I specify for each message. (I often get hundreds of e-mail messages in a week. The subject line allows me to find, filter and sort messages.) You will lose a significant number of points on the assignment if you use the wrong subject line.
- Always send yourself a copy of each e-mail message you send to me, and check immediately to see if you receive the message intact. You are responsible for sending e-mail correctly.
Here is the list of things you have to turn in:
- At the start of class on the first due date email the following items:
- A Flow Chart diagram of a High Level Solution for the problem.
- A Skeletal Outline of the solution with adequate Comments.
Make sure all content is plainly readable and properly formatted.
Email your submission with the subject line: CS2500,prog3.1.
- Send the following item to me by e-mail before midnight on the second due date:
Your final version of the source code, with subject line: CS2500,prog3.f.
Attachments:
Related Questions
. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:
1
Project 1
Introduction - the SeaPort Project series
For this set of projects for the course, we wish to simulate some of the aspects of a number of
. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:
1
Project 2
Introduction - the SeaPort Project series
For this set of projects for the course, we wish to simulate some of the aspects of a number of