# Lab 15
## Lab 15-1.c
```clike
#include <stdio.h>
int get_problem(void);
void get_rate_drop_factor(double *, double *);
void get_kg_rate_conc(double *, double *, double *);
void get_units_conc(double *, double *);
double fig_drops_min(double, double);
double fig_ml_hr(double);
double by_weight(double, double, double);
double by_units(double, double);
int get_problem(void){
printf("Enter the number of the problem you to solve.\n\n");
printf("GIVEN A MEDICAL ORDER IN CALAULATE RATE IN\n");
printf("[1] ml/hr & tubing drop factor drops/min\n");
printf("[2] 1 L for n hr ml/hr\n");
printf("[3] mg/kg/hr & concentration in mg/ml ml/hr\n");
printf("[4] units/hr & concentration in units/ml ml/hr\n");
printf("[5] Quit\n\n");
int opt;
printf("problem -> ");
scanf("%d",&opt);
return opt;
}
// opt 1
void get_rate_drop_factor(double *speed, double *drops){
printf("Enter rate in ml/hr -> ");
scanf("%lf",speed);
printf("Rnter tubing's drop factor(drops/ml) -> ");
scanf("%lf",drops);
double rate=fig_drops_min(*speed,*drops);
printf("The drop rate per minute is %.0lf\n\n",fig_drops_min(*speed,*drops));
}
// opt 3
void get_kg_rate_conc(double *speed, double *kilo, double *conc){
printf("Enter rate in mg/kg/hr -> ");
scanf("%lf",speed);
printf("Enter patient weight in kg -> ");
scanf("%lf",kilo);
printf("Enter concentration in mg/ml -> ");
scanf("%lf",conc);
double rate=by_weight(*speed,*kilo,*conc);
printf("The rate in milliliters per hour is %.0lf\n\n",by_weight(*speed,*kilo,*conc));
}
// opt 4
void get_units_conc(double *speed, double *conc){
printf("Enter rate in units/hr -> ");
scanf("%lf",speed);
printf("Enter concentration in units/ml -> ");
scanf("%lf",conc);
printf("The rate in milliliters per hour is %.0lf\n",by_units(*speed,*conc));
}
double fig_drops_min(double speed, double drops){
return speed*drops/60; // drops/min
}
double fig_ml_hr(double hr){
int rate=1000/hr;
if((int)(rate*10)%10>5) rate+=1;
return (int)rate; // ml/hr
}
double by_weight(double speed, double kilo, double conc){
int rate=speed*kilo/conc;
if((int)(rate*10)%10>5) rate+=1;
return (int)rate; // ml/hr
}
double by_units(double speed, double conc){
int rate=speed/conc;
if((int)(rate*10)%10>5) rate+=1;
return (int)rate; // ml/hr
}
int main(){
int end_flag=0;
int opt;
double speed,drops,kilo,conc;
while(!end_flag){
opt=get_problem();
switch(opt) {
case 1:
get_rate_drop_factor(&speed,&drops);
break;
case 2:
double hour;
printf("Enter number of hour -> ");
scanf("%lf",&hour);
printf("The rate in milliliters per hour is %.0lf\n\n",fig_ml_hr(hour));
break;
case 3:
get_kg_rate_conc(&speed,&kilo,&conc);
break;
case 4:
get_units_conc(&speed,&conc);
break;
case 5:
end_flag=1;
}
}
return 0;
}
```