CS 2500: Project 2 -- rpn calculator

Due Tuesday, April 3, 5:00 pm

 

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), together with a driver program which can handle the operations:


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

Submission: Send me your program files as an attachment to an email. Send the email to tom3@csustan.csustan.edu . Make sure the subject line consists only of "cs2500 project 2" (without the quotes . . .). Make sure your attachments are plain text files (not word-processing files . . .). In the body of your email, be sure to clearly identify yourself (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)

   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 @