Beruflich Dokumente
Kultur Dokumente
int main() {
double volume, timeHours;
int dropsPerMin;
char typeOfFluid;
cout<<"This program computes DRIP RATES\n"
<<"Enter volume in L(liters): ";//prompt
cin>>volume;
volume*=1000;//convert to mL
while(volume!=0)//terminal value is a 0 input
{
cout<<"Enter time in hours prescribed by the medic: ";//prompt
cin>>timeHours;
cout<<"Press B - Blood or Think fluids\n"<<"Press C - Clear
fluids\n"<<"Press O - Given set\n";
cout<<"Type of fluid: ";//prompt
cin>>typeOfFluid;
if(typeOfFluid=='b'||typeOfFluid=='c'||typeOfFluid=='o')
{
typeOfFluid=toupper(typeOfFluid);//to uppercase the input so that
it will not fall to the default case
}
switch(typeOfFluid)//switch statement to determine the formula for the
substance
{
case 'B':
dropsPerMin=dripRateB(volume,timeHours);
cout<<"You entered the following information:"<<endl;
cout<<"Volume: "<<volume<<endl;
cout<<"Time: "<<timeHours<<endl;
cout<<"Type of Fluid: Blood and Thick fluids\n\n";
cout<<"The calculated rate in drops per minute is:
"<<dropsPerMin<<endl;
break;
case 'C':
dropsPerMin=dripRateC(volume, timeHours);
cout<<"You entered the following information:"<<endl;
cout<<"Volume: "<<volume<<endl;
cout<<"Time: "<<timeHours<<endl;
cout<<"Type of Fluid: Clear fluids\n\n";
cout<<"The calculated rate in drops per minute is:
"<<dropsPerMin<<endl;
break;
case 'O':
dropsPerMin=dripRateO(volume, timeHours);
cout<<"You entered the following information:"<<endl;
cout<<"Volume: "<<volume<<endl;
cout<<"Time: "<<timeHours<<endl;
cout<<"Type of Fluid: Given set\n\n";
cout<<"The calculated rate in drops per minute is:
"<<dropsPerMin<<endl;
break;
default:
cout<<"Invalid choice!\n";
cout<<"Press B - Blood or Think fluids\n"<<"Press C - Clear
fluids\n"<<"Press O - Given set\n";
cout<<"Type of fluid: ";
cin>>typeOfFluid;
}
cout<<"Enter volume in L(liters): ";//prompt
cin>>volume;
volume*=1000;//convert to mL
}
system("pause");
return 0;
}