I have tried to get this program to work with no luck. How do you properly use the nested selection structure? (sorry for the lack of braces, I tried getting rid of some for less confusion. Didn't think it would work but thought I might as well try :D). I'm just beginning in CPP.
//Created by Ted
//on 8/2/2011
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
using std::cout;
using std::cin;
using std::endl;
using std::transform;
using std::string;
using std::fixed;
using std::getline;
int main()
{
//Declare variables
string prompt1 = "";
string prompt2 = "";
double num1 = 0.0;
double num2 = 0.0;
double answer = 0.0;
//Prompt for info
cout << "Hello, what's you name? ";
getline(cin, prompt1);
transform(prompt1.begin(), prompt1.end(), prompt1.begin(), toupper);
cout << "What operation would you like to use? ";
getline(cin, prompt2);
transform(prompt2.begin(), prompt2.end(), prompt2.begin(), toupper);
cout << "Ok "<< prompt1 <<", what are your two numbers? \n(seperate numbers with Enter button) \n";
cin >> num1;
cout << "And the second number? ";
cin >> num2;
//Calculate answer
if(prompt2 == "ADD", "ADDITION", "+", "PLUS")
answer = num1 + num2;
else
if(prompt2 == "SUBTRACTION","MINUS", "SUBTRACTION")
answer = num1 - num2;
else
if(prompt2 == "divide", "division", "/", "multiply", "multiplication", "times", "X")
cout << "Sorry, please enter another operation. " << endl;
else
cout << "Sorry, invalid operation." << endl;
//Display answer
cout <<"---------------- \nDear " << prompt1 <<", \nThe answer is "<< answer <<"." << endl;
return 0;
} //End of main function