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 <limits>
using namespace std;
float a, b, c, p, z, y, x;
class Function
{
public:
void welcome()
{
cout << "Welcome!\n";
cout << "Here, I will perform four simple arithmetic equations based upon your input.\n";
cout << "Please input two numbers: ";
}
float Add(float alpha, float bravo)
{
cout << "\nIn Add().\n";
cout << "Finding the sum of " << alpha << " and " << bravo << " ...\n";
return (alpha + bravo);
}
float Subt(float alpha, float bravo)
{
cout << "\nIn Subt().\n";
cout << "Finding the difference of " << alpha << " and " << bravo << " ...\n";
return (alpha - bravo);
}
float Multi(float zulu, float yankee)
{
cout << "\nIn Multi().\n";
cout << "Multiplying the sum of the two integers, " << zulu << " by their difference, " << yankee << " ...\n";
return (zulu * yankee);
}
float Div(float papa, float charlie)
{
cout << "\nIn Div().\n";
cout << "I will now divide " << papa << " by your third input, " << charlie << " ...\n";
return (papa / charlie);
}
};
int main()
{
Function func;
func.welcome();
cin >> a;
cin >> b;
cout << "\nCalling the Add() function... \n";
z=func.Add(a,b);
cout << "The sum is " << z << ".\n";
cout << "\nExcellent! Now we will find the difference of your two numbers... \n";
y=func.Subt(a,b);
cout << "The difference is " << y << ".\n";
cout << "\nNow for the Multiplication part!\n";
cout << "Calling the Multi() function... \n";
p=func.Multi(z,y);
cout << "The product is " << p << " .\n";
cout << "\nLastly, I will divide the product by your third and final input.\n";
cout << "Please enter a third number: ";
cin >> c;
cout << "\nThank you. Transferring you to Div().\n";
x=func.Div(p,c);
cout << "\nProgram Complete!\n";
cout << "The answer is " << x << ".\n";
cout << "\nPress enter to continue...\n";
cin.sync();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
return 0;
}
|