#include <iostream>
#include<cmath>
using namespace std;
int getProblem();
void getRateDropFactor();
void getKgRateConc();
float figDropsMin(float, float);
float byWeight(float, float , float);

int main ()
{   
    int choice;
	
	do{
    choice = getProblem();
	switch(choice){
		case 1 : getRateDropFactor();
	             break;
	    case 2 : getKgRateConc();
	             break;
	    case 3 : cout << "You have chosen to quit the program." << endl << "Thank you for using our system.";
	             break;
	    default : cout << "Please run the system again and choose a problem number between 1 and 3" << endl << endl;
	              break;
	} 
} while( (choice == 1) || (choice==2) && (choice !=3));
 
	return 0;
	
}

int getProblem()
{
	int choice;
	cout << "INTRAVENOUS RATE ASSISTANT\n\n" ;
	cout << "Enter the number of the problem you wish to solve.\n";
	cout << "\tGIVEN A MEDICAL ORDER IN \t\t CALCULATE RATE IN\n";
	cout << "(1) ml/hr & tubing drop factor \t\t\t drops/min \n";
	cout << "(2) mg/kg/hr & concentration in mg/ml \t\t ml/hr \n";
	cout << "(3) QUIT ";
	
	cout << "\n\nProblem => ";
	cin >> choice;
	return choice;
	

}
void getRateDropFactor()
{
	float rate, drop,dm;
	
	cout << "Enter rate in ml/hr => ";
	cin >> rate ;
	
	cout << "Enter tubing's drop factor (drop/ml) => ";
	cin >> drop;
	dm = figDropsMin(rate, drop);
	cout << "The drop rate per minute is " << dm << endl << endl << endl;
	
}

void getKgRateConc()
{
	float rate, w,conc, mh;
	cout << "Enter rate in mg/hr => ";
	cin >> rate;
	cout << "Enter patient weight in kg => ";
	cin >> w;
	cout << "Enter concentration in mg/ml => ";
	cin >> conc;
	mh = byWeight(rate, w, conc);
	cout << "The rate in millilitres per hour is " << mh << endl << endl << endl;
	
}

float figDropsMin(float rate , float drop)
{
	float dm;
	dm = ((rate)*drop)/60;
	return ceil(dm);
}
	
float byWeight(float rate , float w, float conc)
{
	
	float mh;
     mh = rate * w * conc;
     return round(mh);
}











