Thread: Need opinion...
View Single Post
Old Feb 1st, 2005, 9:48 AM   #69
Broax
Hobbyist Programmer
 
Broax's Avatar
 
Join Date: Jan 2005
Location: Porto, Portugal
Posts: 142
Rep Power: 4 Broax is on a distinguished road
Send a message via MSN to Broax
First of all... Sorry for the double post...
Secondly... Well, I know you'll find my programming attempts f***ing pathetic, but I managed to make a very simple calculator all by my own.

It truly sucks, but it does the basic 2+2=4 stuff, and it's a somewhat creative solution for my "how the f*** will I do this" question.

Actually I'm a bit proud of myself!

Anyway, here's the code:

#include <iostream>
using namespace std;

int main()
{
int a;
int b;
string c;
int total;
string end;

           cout << "Select what type of calculation you'll make from +, -, x and /" << endl;
           cin >> c;
           cout << "Specify first value of the calculation:";
           cin >> a;
           cout << "Specify second value of the calculation:";
           cin >> b;
           if (c=="+")
           total=a+b;
           if (c=="-")
           total=a-b;
           if (c=="x")
           total=a*b;
           if (c=="/")
           total=a/b;
           
           cout << "the total is:" << total << endl;
           cout << "Type anything to end this stupid calc-wannabe" << endl;
           cin >> end;
           
           return 0;
           }

Yes... I know... it's stupid, futil and pathetic... but it works! :p

Nevertheless I'd appreciate if someone could tell me how to properly terminate the program.

Anyway... what d'ya think?
__________________
PORTUGALPORTUGA
PORTUGALPORTUGA
PORTUGALPORTUGA
PORTUGALPORTUGA
PORTUGALPORTUGA
Broax is offline   Reply With Quote