Sie sind auf Seite 1von 2

#include <iostream>

#include<cmath>//included to make use of round up or down function

using namespace std;

const double minPerHr=60;//conversion factor for time


const double bloodAndThick = 15;//conversion factor for b choice
const double clearFluids = 20;//conversion factor for c choice

int dripRateB(double &volume, double &timeHours);//function to calculate for option


b
int dripRateC(double &volume, double &timeHours);//function to calculate for option
c
int dripRateO(double &volume, double &timeHours);//function to calculate for option
o

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;
}

int dripRateB(double &volume, double &timeHours)//function to calculate for option


b
{
int dripRate;
double drips;
drips=(volume*bloodAndThick)/(minPerHr*timeHours);
dripRate=round(drips);
return dripRate;
}

int dripRateC(double &volume, double &timeHours)//function to calculate for option


c
{
int dripRate;
double drips;
drips=(volume*clearFluids)/(minPerHr*timeHours);
dripRate=round(drips);
return dripRate;
}

int dripRateO(double &volume, double &timeHours)//function to calculate for option


o
{
int dripRate;
double drips;
double dropsPerMiliL;
cout<<"Enter substance drip per mililiter: ";
cin>>dropsPerMiliL;
drips=(volume*dropsPerMiliL)/(minPerHr*timeHours);
dripRate=round(drips);
return dripRate;
}

Das könnte Ihnen auch gefallen