Im doing a calculator project for my c++ class but my operations dont compute properly and i cant quite figure out whats wrong any input would be greatly appreciated.
//Program Name: Calc
//Author: Charles Covington
//Date: Feb. 20, 2007
//Description : This is a simple calculator
#include
#include
#include
using namespace std;
//prototypes
string upconv(string instring);
void help();
//begin main program
int main () {
//declarations
double memory; //contains value in memory
double display; //contains contents of display
double number; //contains input number
string strInput; //contains an operator or command
char firstChar; //first char of input
char secondChar; //second char of input
int inputLength; //length of input
//show user program description
cout << "Enter ? for help" << endl;
while(true) {
//read input
cin >> strInput;
strInput = upconv(strInput);
//extract first character
firstChar = strInput[0];
inputLength = strInput.length();
if(inputLength==1) {
switch(firstChar) {
case '+':
cin >> number;
display = display + number;
break;
case '-':
break;
case '*':
break;
case '/':
break;
case '=':
break;
case '?':
help();
break;
case 'I':
break;
case 'N':
display = display * -1;
break;
case 'E':
break;
default:
cout <<"Error invalid command" <<endl;
}//end switch
}//end then
else { //2 character command
if(firstChar == 'M') { //memory command
secondChar = strInput[1];
switch(secondChar) {
case 'S':
memory = display;
break;
case 'R':
display = memory;
cout << "Memory equals " << endl;
break;
case '+':
display = memory + display;
break;
case 'C':
break;
default:
cout << "Invalid memory command"<<endl;
}//end switch
}//end of
else {
}
}//end else
cout << display << endl;
}//end while
return 0;
}//end main
string upconv(string instring) {
string newstring=instring;
int len = instring.length();
for(int i=0; i
newstring[i]= toupper(instring[i]);
}//end for
return newstring;
}//end upconv
void help() {
//display help screen
cout << "HELP" << endl;