CS 2500: Project 2 -- rpn calculator

Due Monday, Oct. 17, 10:00 pm (new date)

 

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 implement a stack class (stack of integers), and a driver program. These will be in separate files -- submit both files.

The stack class will need to implement (at least):

Your driver program will implement the following operations:


There is a (similar) standard rpn calculator called 'dc' (desk calculator) on almost all unix systems.

Submission: Use the CS homework submission system. Submit (at least) two files. Be sure to clearly identify yourself in the comments of your program (i.e., with your real name :-).

Input data: The input to the program will come from the console. I will test your program with various examples

Scoring: The maximum possible score for the project will be 80 points. There will be up to 40 points for correct operation of your program, and up to 40 points for style, comments, etc.

Late programs will have their maximum possible score reduced to 0.9 times previous for each calendar day late (i.e., maximum possible score = 80 * (0.9^n) for n days late . . .).


Example: (note: @ stands for typing a return -- the prompt for the calculator is > )

   > 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
   
   > 1 2 3 4 f @
     4 3 2 1 #
   > + + + @
   > p @
   10
   > c @
   > 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 @