[SOLVED] CPSC 121-Lab 6

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon lab-6-w2dtjj.zip (47 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
5/5 - (3 votes)

 

Pointers and Structs

Your program will:

  1. Declare a Calculator object, and initialize it
    1. 0 for both values and + for last operator will be good
    2. You’ll have to initialize the pointer (with “new”) before initializing its value!
  2. Accepts a line of input that will be read like a calculator
    1. Valid operations – The user is prompted, then, without choosing, just provides one of the below patterns
      1. Full expressions: 3+5, when entered, displays/stores 8 (Used below)
      2. Partial expressions: +1, when entered, uses the previous results as a starting point. Continuing from the above example, displays/stores 9
  • Repeat last operation: =, when entered, uses the previous operation’s results with the same operator and Right Hand value. If entered after the above statement, would display/store 10.
  1. You can make this run when no input is provided, just document it and let me know as the user!
  2. Quit: q, when entered, ends the execution of the program
  1. Apart from any whitespace that may be in the input string, any characters that are neither digits, an operator (+-*/%), or the quit command, should not be accepted; meaning the calculator command is rejected with a message given to the user. If the user’s input is rejected, no action should be taken.
  1. Based on the user’s valid input, appropriately calculate, display, and store the answer in the LHValue member of your Calculator object
    1. void processInput(Calculator * calc, string userInput)
    2. Function definition above must be used (argument types can’t be changed)
  2. Repeat step 2

Note: Don’t allow for division by 0!

If you’re unfamiliar with pointers, wait, look to the slides and/or try working on this assignment with the pointer temporarily converted to an ordinary variable.

Points:

  • – Documentation, readability, format

1.5 – Proper use of Pointers

1.5 – Proper use of Structs

  • – Proper program flow (conditionals, loops, etc)

2 – Filename and Header 2 – Output testing

 

1 file · 47.0 KB

  • lab-6-w2dtjj.zip 47.0 KB