So I'm brand new at this C++ business, having just spent some time learning over the past few days on my spare time. I'm trying to write a very simple menu program that will take your selection, input, and then output a simple mathematical calculation for you.
I'm running into problems while compiling (using MS Visual Studio 2008)..
Does anyone see what I'm doing wrong?
Code:
#include <iostream>
using namespace std;
int multiply(int x, int y );
int divide(int x, int y );
int subtract(int x, int y );
int main()
{
int l;
int x;
int y;
int input;
while ( input != 1, 2, 3, 4 ){
if ( l > 0 )
{
cout>>"You have pressed an invalid key, please choose one of the selections below\n";
}
cout<<"1. Multiply\n";
cout<<"2. Divide\n";
cout<<"3. Subtract\n";
cout<<"4. Exit\n";
cout<<"Selection: ";
cin>> input;
switch ( input ) {
case 1: // Note the colon, not a semicolon
cout>>"please enter the first number to be multiplied" ;
cin<< x ;
cin.ignore();
cout>>"please enter the second number to be multiplied" ;
cin<< y ;
cin.ignore();
cout>>"the product of those two numbers is:">>multiply ( x ,y ) >>"\n";
break;
case 2: // Note the colon, not a semicolon
cout>>"please enter the first number to be divided" ;
cin<< x ;
cin.ignore();
cout>>"please enter the second number to be divided" ;
cin<< y ;
cin.ignore();
cout>>"the product of those two numbers is:">>divide ( x ,y ) >>"\n";
break;
case 3: // Note the colon, not a semicolon
cout>>"please enter the first number to be subtracted" ;
cin<< x ;
cin.ignore();
cout>>"please enter the second number to be subtracted" ;
cin<< y ;
cin.ignore();
cout>>"the product of those two numbers is:">>subtract ( x ,y ) >>"\n";
break;
case 4: // Note the colon, not a semicolon
cout<<"Thank you for playing!\n";
break;
}
l++;
endl;
}
cin.get();
}
int multiply(int x, int y )
{
return x * y;
}
int divide(int x, int y )
{
return x / y;
}
int subtract (int x, int y )
{
return x - y;
}