Need Help with C++ Calculator

This is the code to my calculator. It is supposed to be set up like an accountants in that you start at 0 and can keep performing operations on it. Currently I need help developing a running total, as well as being able to press 'x' to exit the program. Any help is useful!
--------------------------------------------------------------------------------

#include "stdafx.h"
#include <iostream>
using namespace std; //allows compiler to recognize terms from library such as endl, cout, etc.

int main() //declares the main function
{
double num = 0; //to clarify the variable name, num is short for number
double num2;
char operation; //stores the addresses of +, -, *, and /
char quit;
do
{
cout << "Hello! My name is Jeff Gallimore. Welcome to my calculator :)" << endl << endl; //friendly greeting to the user
cout << "To exit the program, press 'x'" << endl;

cout << "--------------------------------------------------------------------------------" << endl;
cout << "Total: 0" << endl;
cout << " ";
cin >> operation >> num2;
switch (operation){ //replaces if statement and covers all mathematical operations
case '+':
cout << "----------" << endl << "Total: " << num + num2 << endl;
if (num == 0)
num2 += num;
break;
case '-':
cout << "----------" << endl << "Total: " << num - num2 << endl;
break;
case '*':
cout << "----------" << endl << "Total: " << num * num2 << endl;
break;
case '/':
if (num2 == 0)
cout << "Improper operation, not dividable by 0" << endl; //clears calculator and sends the user back to make another calculation
else
cout << "----------" << endl << "Total: " << num / num2 << endl;
break;
}


cin >> quit;
} while (quit == 'x' || quit == 'X'); //gives option to clear all calculations
system("pause");
return 0;
}
Topic archived. No new replies allowed.