CISC220 F2023 Lab3

From class_wiki
Revision as of 10:09, 14 September 2023 by Cer (talk | contribs) (Created page with "==Requirements== '''(5 points)''' Using the [https://cplusplus.com/reference/stack/stack/ STL stack class], implement a ''postfix expression evaluator'' as discussed in class...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Requirements

(5 points) Using the STL stack class, implement a postfix expression evaluator as discussed in class on 9/12. Your program should take a single input filename on the command line, which will contain a single expression on the first line of the file. Ignore anything and everything after this first line. Expressions consist of decimal numbers (doubles) and any of 5 symbols, all separated by whitespace. The 5 symbols are +, -, *, /, and ^ for addition, subtraction, multiplication, division, and exponentiation. You will evaluate these expressions with double precision using the stack-based approach below, and output your final answer rounded to the nearest integer with cout.

  • If a number is read, push it on the stack
  • If a symbol is read, pop the top two numbers on the stack, apply the operator, and push the result
  • If any of the below errors are detected, print "ERROR":
    • Attempting to pop when the stack is empty
    • Not having exactly one number in the stack at the end of evaluation
    • An input which is neither a number nor from the symbol set
    • A number which is too large to represent as double
    • An operation which results in something that is either infinite or "not a number."
  • A handful of test input files and correct output for them are provided. You should create many more of your own to thoroughly test your solution. The Gradescope autograder tests will not be available until at least Sunday
  • The required functions above are the minimum -- you may create additional "helper" functions and/or member variables as needed. No STL or outside libraries may be referenced in your SL_List class.
  • You may optionally work with a partner on this assignment. Any late days used will be subtracted from both of your balances.

Submission

  • Let's try submitting completely through Gradescope this week. You will submit exactly two files: (1) "README" (no PDF or other fancy formatting, just plain text) and (2) "sl_list.cpp". As before, the README should contain any AI tool citations/explanations, notes on any limitations or issues with your code, your interpretation of any ambiguities in the assignment instructions, and the names of yourself and your partner if you had one. The code file should also have your name(s) and AI citations per the syllabus.
  • Resubmit as many times as you like until the deadline, but be aware that the submission window is kept open for some students to use late days, so a resubmission 2 days after the deadline is not free.
  • As I said in class, although 5 possible points will be available through the autograder, this is not guaranteed to be your final lab grade. The TAs and I will be checking that your submission (both README and code) satisfies any or all of the above requirements for you to earn full credit.