QuestionQuestion

Please use a .h / .cpp file

Create a calculator program which allows the user to add, subtract, multiply, or divide two numbers. Store each of the results in a stack. Allow the user to review the Nth previous result (i.e. print the Nth previous result to the screen).

Example​:
Select an operation:
1) Addition
2) Subtraction
3) Multiplication
4) Division
5) Review History
> 1

Enter two numbers:
> 5
> 7

Result: 5 + 7 = 12

Select an operation:
1) Addition
2) Subtraction
3) Multiplication
4) Division
5) Review History

> 5

Which previous answer would you like to review?: > 1

Result: 5 + 7 = 12

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <cstdlib>
#include <iostream>
#include <vector>
#include <valarray>
#include <ratio>
using namespace std;

// constant values
const int ADD = 1;
const int SUB = 2;
const int MUL = 3;
const int DIV = 4;

/**
* show menu
* @return user's selection
*/
int menu();

/**
* show result to screen
* @param lefts vector of number
* @param rights vector of number
* @param operators vector of operator
* @param index index of the answer
*/
void show(const vector<int> & lefts, const vector<int> & rights,
       const vector<int> operators, unsigned int index);

/**
* get number from keyboard
* @param lefts vector of number
* @param rights vector of number
*/
void get(vector<int> & lefts, vector<int> & rights);

int main(int argc, char** argv) {...

By purchasing this solution you'll be able to access the following files:
Solution.cpp.

$14.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats