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
|
#include <iostream>
#include <string>
using namespace std;
void programInformation();
void inputData(int &nOne, int &dOne, int &nTwo, int &dTwo, char slash, char operand);
void calculationFraction(int &nOne, int &dOne, int &nTwo, int &dTwo, int &nThree, int &dThree, char slash, char operand);
void displayResult(int &nOne, int &dOne, int &nTwo, int &dTwo, int &nThree, int &dThree);
int main()
{
int nOne;
int nTwo;
int dOne;
int dTwo;
int nThree;
int dThree;
char slash;
char operand;
programInformation();
inputData(nOne, dOne, nTwo, dTwo, slash, operand);
calculationFraction(nOne, dOne, nTwo, dTwo, nThree, dThree, slash, operand);
return 0;
}
void programInformation()
{
cout << "Welcome to my Fraction Calculation Program!" << endl;
cout << "Please follow instructions carefully." << endl;
}
void inputData(int &nOne, int &dOne, int &nTwo, int &dTwo, int &nThree, int &dThree, char slash, char operand)
{
cout << "Enter your operation like 1/2 + 1/4." << endl;
cin >> nOne >> slash >> dOne >> operand >> nTwo >> slash >> dTwo;
cout << "Enter your expect result." << endl;
cin >> nThree >> slash >> dThree;
}
void calculationFraction(int &nOne, int &dOne, int &nTwo, int &dTwo, int&nThree, int&dThree, char slash, char operand)
{
if (operand == *)
{
n1 * d2 + n2 * d1 = n3
n2 * d2 = d3
}
else
{
cout << "failed.";
}
}
|