#include<iostream>
#include<cmath>
using namespace std;

int getProblem();
void getRateDropFactor();
void getKgRateConc();
float fidDropsMin(float, float);
float byWeight(float,float,float);

int input;
int main()
{
	
	
	do{
		int a=getProblem();
		
		if (a==1)
			getRateDropFactor();
			//a=getProblem();
		else if (a==2)
			getKgRateConc();
		else if (a==3)
		{
			cout<<"You have choosen to quite the program."<<endl;
			cout	<<"Thank you for using our system."<<endl<<endl;
				break;}
				else{
					cout <<"For choices which are not in the range of 1 to 3 example -1 or 6 : "<<endl;
					cout<<a;
					cout << "Please run the system again"<< endl << endl;
					break;
				}
				 
	}while((input!=-1)&&(input!=6));
	
	
	return 0;
}

int getProblem()
{	
		cout<<"INTRAVENOUS RATE ASSISTANT"<<endl<<endl
		<<"Enter the number of the problem you wish to solve."<<endl
		<<"\tGIVEN A MEDICAL ORDER IN\t\tCALCULATE RATE IN"<<endl
		<<"(1) ml/hr & tubing drop factor\t\tdrops/min"<<endl
		<<"(2) mg/kg/hr & concentration in mg/ml\t\tml/hr"<<endl
		<<"(3) QUIT"<<endl;
	cout<<"Problem => ";	
	cin>>input;
	return input;
}
void getRateDropFactor( )
{
	float r,f;
	cout<<"Enter rate in ml/hr => ";
	cin>>r;
	cout<<"Enter tubing's drop factor(drops/ml) => ";
	cin>>f;
	cout<<"The drop rate per minute is "<< fidDropsMin(r,f)<<"."<<endl<<endl;
} 
void getKgRateConc()
{
	float r,w,c,m;
	cout<<"Enter rate in mg/hr => ";
	cin>>r;
	cout<<"Enter patient weight in kg => ";
	cin>>w;
	cout<<"Enter concentration in mg/ml => ";
	cin>>c;
	cout<<"The rate in millilitres per hour is "<<byWeight( r,w,c)<<"."<<endl<<endl;
	
}

float fidDropsMin(float rt, float fc)
{
	int drops = ceil((rt/60)*fc);
	return drops;
}
float byWeight(float rt1,float w1,float c1)
{
	int rate= round(rt1*w1*c1);
	return rate;
}

