
Patrick B. answered 05/21/21
Math and computer tutor/teacher
using namespace std;
#include <iostream>
#define EPSILON (0.00000000001) //good to 10 digits
double InputResValue(char * strMsgPrompt=NULL)
{
double resVal=0;
while (resVal<EPSILON)
{
if (strMsgPrompt==NULL)
{
cout << "Please input the number :>";
}
else
{
cout << strMsgPrompt << " :>";
}
cin >> resVal;
}
return(resVal);
}
Go()
{
double resONE=0, resTWO=0, resTHREE=0;
resONE = InputResValue("Please input the 1st number :>");
resTWO = InputResValue("Please input the 2nd number :>");
resTHREE = InputResValue("Please input the 3rd number :>");
resONE = 1/resONE;
resTWO = 1/resTWO;
resTHREE = 1/resTHREE;
double InvResTOT = resONE + resTWO + resTHREE;
if (InvResTOT > EPSILON)
{
InvResTOT = 1/InvResTOT;
cout << InvResTOT << endl;
}
else
{
cout << " DIVISION BY ZERO EXCPETION " << endl;
}
}
int main()
{
Go();
}