Question Description
struct Calculator {
long long LHValue;
long long * RHValue;
char lastOperator;
};
Pointers and Structs
We will be creating a calculator program that uses a struct definition provided to you. Your program will:
- Declare a Calculator object, and initialize it
- 0 for both values and + for last operator will be good
- You’ll have to initialize the pointer (with “new”) before initializing its value!
- Accepts a line of input that will be read like a calculator
- Valid operations – The user is prompted, then, without choosing, just provides one of the below patterns
- Full expressions: 3+5, when entered, displays/stores 8 (Used below)
- 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.
- You can make this run when no input is provided, just document it and let me know as the user!
- Quit: q, when entered, ends the execution of the program
- 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.
- Valid operations – The user is prompted, then, without choosing, just provides one of the below patterns
- Based on the user’s valid input, appropriately calculate, display, and store the answer in the LHValue member of your Calculator object
- void processInput(Calculator * calc, string userInput)
- Function definition above must be used (argument types can’t be changed)
- Repeat step 2
Note: Don’t allow for division by 0!
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Place Order” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.