1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
double a, b;
char operation, more, use;
cout << "Which do you want to use c1 for calculator c2 for converter\n\n";
cin >> use;
if (use == 'c1' || use=='C1')
cout << "Calculater program by Ryu D. Nakasato" << endl;
cout << "-----------------------------------------------------------------------" << endl;
cout << "Copyright law protected if copied or edited without my permission person is \nsubjected to pay $100 per letter or space";
cout << "\n\n";
do
{
cout << " Please enter an operation which you like to calculate (+,-,*,/,s)";
cout << " \n [s stands for swap]:";
cin >> operation;
cout << endl << endl;
cout << " Please enter two numbers to apply your requested operation(";
cout << operation << "):" << endl << " 1st num:";
cin >> a;
cout << " 2nd num:";
cin >> b;
cout << endl;
switch (operation)
{
case'+':
cout << "The addition of two numbers (" << a << "," << b << "):";
cout << a + b << endl;
break;
case'-':
cout << "The substraction of two numbers (" << a << "," << b << "):";
cout << a - b << endl;
break;
case'*':
cout << "The multiplication of two numbers (" << a << "," << b << "):";
cout << a*b << endl;
break;
case'/':
cout << "The division of two numbers (" << a << "," << b << "):";
if (b == 0)
{
cout << "not valid" << endl;
}
cout << (a / b) << endl;
break;
case's':
cout << "The swap of two numbers (" << a << "," << b << "):";
swap(a, b);
cout << "1stnumber=" << a << " and 2nd number=" << b << endl << endl;
break;
default:
cout << "unknown command" << endl;
}
cout << "Continue[Y/N]? ";
cin >> more;
cout << endl << endl;
} while (more == 'y' || more == 'Y');
if (use == 'c2'||use=='C2')
do{
cout << "hehe";
} while (more == 'y' || more == 'Y');
}
|