View Single Post
  #1 (permalink)  
Old April 12th, 2007, 03:17 PM
nerdman978 nerdman978 is offline
Registered User
 
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default can't get my program to work, help please

Ok I want a program to do basic calculator functions (mainly to show off to my friends), but I keep f*ing up the program. Here is what I have so far.

#include <iostream>

using namespace std;

int main()
{
    int answer;
    char function;
    int a;
    int b;
    int c;
    int d;
    cout<<"***Please enter first number in equation.";
    cin>> a;
    cin.ignore();
    cout<<"Please enter second number.";
    cin>> b;
    cin.ignore();
    cout<<"Please enter a function.";
    cin>> function;
    cin>> a == *
    cin>> b == -
    cin>> c == +
    cin>> d == /
    if ( function == a ) {
         cout<< a-b;
    }
    else if ( function == b ) {
         cout<< a+b;
    }
    else if ( function == c ) {
         cout<< a*b;
    }
    else if ( function == d ) {
         cout<< a/b;
    }
}

Any suggestions would be great.

I will make C++ my bitch.
Reply With Quote