Question: I feel that this code is not complete, but I don't know how to polish it. So how would I make this code better? #include
I feel that this code is not complete, but I don't know how to polish it. So how would I make this code better?
#include
using namespace std;
int main() { //Declaration the variables int ch=1; double visc, dens, dia, vel; //make the system repeat while(ch!=3) { //Menu cout << " ---------------Fluid Flow Velocities--------------" << endl; cout << "1. Laminar Velocity" << endl; cout << "2. Turbulent Velocity" << endl; cout << "3. Exit " << endl; cout << "Enter your choice : "; cin >> ch; //if the user wants to compute velocity, then if(ch==1 || ch==2) { //declare and initialize variable liq to 5 int liq=5; //loop until liq not equal to 1, 2, 3 or 4 while(!(liq==1 || liq==2 || liq==3 || liq==4)) { //Menu cout << " Choose the liquid " << endl; cout << " 1. Ethyl alcohol" << endl; cout << " 2. Methyl alcohol" << endl; cout << " 3. Propyl alcohol" << endl; cout << " 4. Water" << endl; cout << " Enter your choice : "; cin >> liq; //switch liq switch(liq) { //if liq=1. i.e, Ethyl alcohol case 1: visc=2.29*pow(10,-5); dens=1.527; break; //if liq=2. i.e, Methyl alcohol case 2: visc=1.17*pow(10,-5); dens=1.531; break; //if liq=3. i.e, Propyl alcohol case 3: visc=4.01*pow(10,-5); dens=1.556; break; //if liq=4. i.e, Water case 4: visc=1.90*pow(10,-5); dens=1.940; break; } } //prompt the user to enter the diameter of the pipe cout << " Enter the diameter of the pipe (in ft) : "; cin >> dia; } //switch ch switch(ch) { // if ch=1. Laminar velocity case 1: vel=(2100.0)*(visc/(dens/dia)); cout << "Laminar velocity : " << vel << " ft/sec" << endl; break; // if ch=2. Turbulent velocity case 2: vel=(4000.0)*(visc/(dens/dia)); cout << "Turbulent velocity : " << vel << " ft/sec" << endl; break; } cout << "--------------------------------------------------" << endl; } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
