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
|
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
void printInformation ();
void askQuestions(double df, double ds, double fv);
void displayResults(double df, double ds, double fv);
int main()
{
double df, ds, fv;
printInformation();
askQuestions (df, ds, fv);
displayResults(df, ds, fv);
void askQuestions (float df, float ds, float fv);
{
cout << "Please enter a value for fluid density " << endl;
cin >> df ;
cout << "Please enter a value for solid density " << endl;
cin >> ds;
cout << "Please enter a value for fluid viscosity " << endl;
cin >> fv ;
}
return 0;
}
//Constants display
void printInformation ()
{
cout << "Distance to bottom of tank = 20.0 cm" << endl;
cout << "Radius of the particle = 0.5 cm" << endl;
cout << "Local value of g (gravity) = 980.00 cm/s^2" << endl;
cout << endl;
}
void displayResults(double df, double ds, double fv, double v,
double t);
{
cout << endl;
cout << fixed << setprecision(2);
cout << "Fluid density: " << setw (10) << df << " g/cm^3" << endl;
cout << "Solid density: " << setw (10) << ds << " g/cm^3" << endl;
cout << "Fluid viscosity: " << setw (8) << fv << " g/cm-s" << endl;
cout << "Velocity: " << setw(15) << v << " cm/s" << endl;
cout << "Falling time: " << setw (11) << t << " s" << endl;
}
}
double addNumbers (double df, double ds, double fv, double g, double r, double d, double v, double t)
{
r=0.5, g=981, d=20;
v = ((2.0/9)*((ds-df)/fv)*g*r*r)/100;
t = (d/v);
return v
}
double addNumbers (double df, double ds, double fv, double g, double r, double d, double v, double t)
{
r=0.5, g=981, d=20;
v = ((2.0/9)*((ds-df)/fv)*g*r*r)/100;
t = (d/v);
return t
}
|