Im making a calculator, and I can't seem to get it to restart.
I know i have to use some kind of loop, but I just can't get it to work.
Heres a bit of my calc just to show you.
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <windows.h>
#define PI 3.14159265
using namespace std;
int main()
{
double param, result, exp;
float b = 0, c = 0, d = 0, e= 0, f = 0;
float w =0 , x=0, y=0;
int z=0;
char a;
int t2, t3, g = 0;
char Q, q, R, r;
cout << "Welcome to the Ultimate Calculator. Copyright Daniel Xie 2008" << endl;
cout << "\n\n\nPlease enter your operation. First number, then the operation, then the second number.\n(eg. 2*6 or 5+3)\n****If there is no 2nd number then just put in 0.****\n\n* = multiplication\n/ = division with decimal answer\n+ = addition\n- = subtraction\ny = square root\nu = cube root\np = exponent (1st number to the power of 2nd number)\nc = cosine\ns=sine\nt=tangent\n\n\n\n";
cin >> b;
cin >> a;
cin >> c;
cin.ignore();
while (a != Q || a != q || a != R || a != r)
{
switch(a)
{
case '+': d = b+c;
cout <<"\n\nAnswer: " << d<< endl;
cin.get();
break;
case '-': d = b-c;
cout <<"\n\nAnswer: " << d <<endl;
cin.get();
break;
case '*': d = b*c;
cout <<"\n\nAnswer: " << d << endl;
cin.get();
break;
case '/': d = b/c;
cout <<"\n\nAnswer: " << d << endl;
cin.get();
break;
case 'y': d = sqrt (b);
cout <<"\n\nAnswer: " << d << endl;
cin.get();
break;
case 'u': d = pow(b,1.0/3.0);
cout <<"\n\nAnswer: " << d <<endl;
cin.get();
break;
case 'p': d = pow(b,c/1.0);
cout << "\n\nAnswer: "<< d << endl;
cin.get();
break;
case 'c': d = cos (b*PI/180);
cout << "\n\nCosine of " << b << "is " << d << endl;
cin.get();
break;
case 's': d = sin (b*PI/180);
cout << "\n\nSine of " << b << "is " << d << endl;
cin.get();
break;
case 't': d = tan (b*PI/180);
cout << "\n\nTangent of " << b << "is " << d << endl;
cin.get();
break;
default: cout << "Invalid operation, please try again. " << endl;
cin.get();
return 0;
break;
}
}
}
Can someone show me how to restart this?