Hi,
yesterday i started to learn c++ and now i just finished my first c++ calculator:
#include <iostream> using namespace std; int main (void) { cout << "Calculator" << endl << "by vollhorst" << endl << endl; cout << "Please chose an operation:" << endl << endl; cout << "\t 1 for + (addition)" << endl; cout << "\t 2 for - (suntraction)" << endl; cout << "\t 3 for * (multiplication)" << endl; cout << "\t 4 for / (division)" << endl; cout << "\t 5 for % (percent)" << endl << endl; cout << "Operation:"; int i1; cin >> i1; cout << endl << "Please enter your first value:"; double d1; cin >> d1; // First value for the operation cout << endl << "Please enter your second value:"; double d2; cin >> d2; // Second value for the operation double d3; if (i1 == 1) d3 = d1 + d2; // decision which operation should be executed + definition of the operation if (i1 == 2) d3 = d1 - d2; // decision which operation should be executed + definition of the operation if (i1 == 3) d3 = d1 * d2; // decision which operation should be executed + definition of the operation if (i1 == 4) d3 = d1 / d2; // decision which operation should be executed + definition of the operation if (i1 == 5) d3 = (d1 /100) * d2; // decision which operation should be executed + definition of the operation cout << endl << endl << "Result:" << d3 << endl << endl;// output cin.get(); cin.get(); return(0); }
What do you think about it??
Comment