//HAM JING YI A19EC0048 990105029068     14/11/2019  SECTION 02
//CHUA CHEN WEI A19EC0038 990520115297   14/11/2019  SECTION 02

#include <iostream>
#include <cmath>
using namespace std ;

int getproblem ()
{
	int p ;
	
	
	cout << endl << "Enter the number of the problem you wish to solve." << endl ;
	cout << "    GIVEN A MEDICAL ORDER IN \t\t \t\t CALCULATE RATE IN" << endl;
	cout << "(1) ml/hr & tubing drop factor \t\t\t\t    drops/min" << endl ;
	cout << "(2) mg/kg/hr & concentration in mg/ml \t\t\t    ml/hr" << endl ;
	cout << "(3) QUIT " << endl << endl  ;
	
	cout << "Problem => "  ;
	cin >> p ;
	return p ;
}

void getRateDropFactor (float &R , float &T)
{
	cout << "Enter rate in ml/hr => " ;
	cin >> R ;
	cout <<"Enter tubing's drop factor(drops/ml) => " ;
	cin >> T ;
}

void getKgRateConc (float &r , float &c , float &w)
{
	cout << "Enter rate in mg/hr => " ;
	cin >> r ;
	cout << "Enter patient weight in kg => " ;
	cin >> w ;
	cout << "Enter concentration in mg/ml => " ;
	cin >> c ;
	
}

float figDropsMin (float R , float T)
{
	float D ;
	
	D = ceil ( (R*T) / 60.0 ) ;
	 
	return D ;
}

float byWeight (float r ,float c ,float w)
{
	float R ; 
	
	R = round (r*c*w );

	return R ;
}
 
int main ()
{
	float r , t ,R ,C ,W ;
	int P , d ,b ;
	
	cout << "INTRAVENOUS RATE ASSISTANT" << endl ;
	
	do
	{
	P = getproblem () ;
	
	if (P==1)
	{
	getRateDropFactor (r , t) ;
	d = figDropsMin ( r ,  t) ;
	
	cout << "The drop rate per minute is " << d << endl ;
	}
	else if (P==2)
	{
	getKgRateConc (R , C , W) ;
	b=byWeight ( R , C , W) ;
		
	cout << "The rate in millilitres per hour is "	<< b << endl ;
	}
	else if (P==3)
	{
		cout << "You have chosen to quit the program." << endl << "Thank you for using our system." << endl;
		return 0;
	}
	else 
	{
	cout << "Please run the system again and choose a problem number between 1 and 3." << endl ;
	return 0;
	}
	
}while (1) ;
	
	
}

