//MOHAMAD AMIN HAZEEQ BIN HISHAM                   
//000804-01-1523
//MUHAMMAD ARIFF FANSURI ABDULRAZAK BIN ROHAIZAD   
//000705-10-0467
//SECTION 2 
//12 NOVEMBER 2019

#include <iostream>
#include <cmath>
using namespace std;

int getProblem()
{
	int input;
	cout<<"Enter the number of the problem you wish to solve.\n";	
	cout<<"     GIVEN A MEDICAL ORDER IN             CALCULATE RATE IN"<<endl;
	cout<<"(1) ml/hr & tubing drop factor              drops/min"<<endl;
	cout<<"(2) mg/kg/hr & concentration in mg/ml       ml/hr"<<endl;
	cout<<"(3) QUIT"<<endl;
	
	cout<<"\nProblem => ";
	cin>>input;
	return input;
}
void getRateDropFactor(float& rate1,float& drop1)
{
	cout<<"Enter rate in ml/hr => ";
	cin>>rate1;
	cout<<"Enter tubing's drop factor (drop/ml) => ";
	cin>>drop1;
}
void getKgRateConc(float& rateI,float& weightI,float& concI)
{
	cout<<"Enter rate in mg/hr => ";
	cin>>rateI;
	cout<<"Enter patient weight in kg => ";
	cin>>weightI;
	cout<<"Enter concentration in mg/ml => ";
	cin>>concI;
	
}
float figDropMin(float& rate,float dropF)
{
	float drpm;
	drpm = ceil(rate*dropF/60);
	return drpm;
		
}
int byWeight(float& rateI,float& weightI,float& concI)
{
	float out;
	out=round(rateI*weightI*concI);
	return out;
}
int main()
{
	float a1,a2,a3,a4,a5;
	float output,out;
	int progrun=0;
	int x=0;
	cout<<"INTRAVENOUS RATE ASSISTANT"<<endl<<endl;
	
	do
	{
	progrun=getProblem();
	switch(progrun)
	{
		case 1:
			getRateDropFactor(a1,a2);
		    output=figDropMin(a1,a2);
            cout<<"The drop rate per minute is "<<output<<"."<<endl<<endl;
			break;
		
		case 2:
			getKgRateConc(a3,a4,a5);
			out=byWeight(a3,a4,a5);
			cout<<"The rate in millilitres per hour is "<<out<<"."<<endl<<endl;
			break;
		case 3:
		    cout<<"You have chosen to quit the program. "<<endl;
			cout<<"Thank you for using our system. "<<endl;
			x=1;
			break;
		
		default:
		    cout<<"Please run the system again and choose a problem number between 1 and 3."<<endl<<endl;
			break;
					
			
			
		    	
	}
	
	
		
	}while(x==0);
	
	
	return 0;
}
