Apr 20, 2015 at 11:10am UTC
Hello
My problem is , i want to make a simple calculator , in the console i want afterall the user to choose what type of operation he want pressing a key like i mentioned in the title the keys would be F1,F2,F3 , i'm not finding in the internet the code to the detection of a press key like what i want.
Thank you
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
#include <iostream>
using namespace std;
int F1 (int x, int y)
{
cout << "Enter a number: " << endl;
cin >> x;
cout << "Enter a number: " << endl;
cin >> y;
int answer = x + y;
return answer;
}
int F2 (int z, int c)
{
cout << "Enter a number: " << endl;
cin >> z;
cout << "Enter a number: " << endl;
cin >> c;
int minusanswer = z - c;
return minusanswer;
}
int F3 (int v, int b)
{
cout << "Enter a number: " << endl;
cin >> v;
cout << "Enter a number: " << endl;
cin >> b;
int multipanswer = v * b;
return multipanswer;
}
int main()
{
cout << "What Type of calculation do you wanna make? " << endl;
cout << "F1--> addition " << " F2-->subtraction " << " F3-->multiplication" << endl;
if (F1)
F1(1,1);
else if (F2)
F2(2, 2);
else if (F3)
F3(2, 2);
return 0;
}
Last edited on Apr 20, 2015 at 12:12pm UTC