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 69 70 71 72 73 74
|
#include <iostream>
#include <string>
#include <math.h>
#include <Windows.h>
using namespace std;
void main(){
HANDLE hConsole;
hConsole = GetStdHandle (STD_OUTPUT_HANDLE);
int input1, input2;
char math = ('+','-','/','*');
SetConsoleTextAttribute (hConsole, 6);
cout<<" Simple Calculator 3.5v.\n";
cout<<" Develop by Mercier\n\n";
SetConsoleTextAttribute (hConsole, 7);
cout<<"What type of mathematic operation do you like to use? (+,-,*,/)\n\n";
cin>>math;cout<<endl;
if (math == '+'){
SetConsoleTextAttribute (hConsole, 2);cout <<" You have choosen addition operation.\n\n";SetConsoleTextAttribute (hConsole, 7);
cout <<"What is your first number(s)?\n";
cin>>input1;cout<<"\n";
cout<<"What is your second number(s)?\n\n";
cin>>input2;cout<<"\n";
cout<<"Your total addition for both numbers is "<<input1 + input2<<endl<<endl;
}
if (math == '-'){
SetConsoleTextAttribute (hConsole, 4);cout <<" You have choosen substraction operation.\n\n";SetConsoleTextAttribute (hConsole, 7);
cout <<"What is your first number(s)?\n\n";
cin>>input1;cout<<"\n";
cout<<"What is your second number(s)?\n";
cin>>input2;cout<<"\n";
cout<<"Your total substraction for both numbers is "<<input1 - input2<<endl<<endl;
}
if (math == '*'){
SetConsoleTextAttribute (hConsole, 6); cout <<" You have choose multiplication operation\n\n";SetConsoleTextAttribute (hConsole, 7);
cout <<"What is your first number(s)?\n";
cin>>input1;cout<<"\n";
cout<<"What is your second number(s)?\n";
cin>>input2;cout<<"\n";
cout<<"Your total multiplication for both numbers is "<<input1 * input2<<endl<<endl;
}
if (math == '/'){
SetConsoleTextAttribute (hConsole, 3); cout <<" You have choosen devision operation\n\n";SetConsoleTextAttribute (hConsole, 7);
cout <<"What is your first number(s)?\n";
cin>>input1;cout<<"\n";
cout<<"What is your second number(s)?\n";
cin>>input2;cout<<"\n";
cout<<"Your total devision for both numbers is "<<input1 / input2<<endl<<endl;
}
else if (math == 'x');{
cout<<"You can only put these four math symbol:\n";
cout<<"(+) for addition.\n";
cout<<"(-) for substraction.\n";
cout<<"(*) for multiplication.\n";
cout<<"(/) for devision."<<endl<<endl;
}
//unfinish calculator kalau user type lain, error keluar "You not put right input".
system ("pause");
}
| |