#include <iostream>
using namespace std;
int main() { int x; int y; int choose; cout<<"Command Line Calculator\n-Marevix, 2004.\n\n"; cout<<"Please select your form of calculation:\n"; cout<<"1= Add\n2= Subtract\n3= Multiply\n4= Divide\n5= Exit\n"; cin>> choose; cin.ignore(); if ( choose == 1 ) { cout<<"\nPlease enter two numbers to be added.\n"; cin>> x >> y; cin.ignore(); cout<<"Answer: "<< x + y <<"."; cin.get(); return (0); } else if ( choose == 2 ) { cout<<"\nPlease enter two numbers to be subtracted.\n"; cin>> x >> y; cin.ignore(); cout<<"Answer: "<< x - y <<"."; cin.get(); return (0); } else if ( choose == 3 ) { cout<<"\nPlease enter two numbers to be multiplied.\n"; cin>> x >> y; cin.ignore (); cout<<"Answer: "<< x * y <<"."; cin.get(); return (0); } else if ( choose == 4 ) { cout<<"\nPlease enter two numbrs to be divided.\n"; cin>> x >> y; cin.ignore(); cout<<"Answer: "<< x / y <<"."; cin.get(); return (0); } else if ( choose == 5 ) { cout<<"Goodbye."; cin.get(); return (0); } else { cout<<"\nYou entered an invalid answer, terminating due to lack-of-info bug. Hahah."; cin.get(); return (0); } }
Amarth's idea worked. Here's a calculator.
|