#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;
   
void getRateDropFactor(float &x, float &y)
{
	cout<<"Enter rate in ml/hr => ";
	cin>>x;
	cout<<"Enter tubing's drop factor (drops/ml) => ";
	cin>>y;
}

float figDropsMIn (float &x, float &y )
{
	return x*y/60.0;
}

void getKgRateConc(float&a, float &b, float &c)
{
    cout<<"Enter rate in mg/hr => ";
	cin>>a;
	
	cout<<"Enter patient weight in kg => ";
	cin>>b;
	
	cout<<"Enter concentration in mg/ml => ";
	cin>>c;
	
	
}

int byWeight (float a, float b, float c)
{
	return a*b*c;
}

int getProblem ()
{
   
  cout<<"\nEnter the number of the problem you wish to solve. "<<endl;
  
  cout<<setw(30)<<"GIVEN A MEDICAL ORDER IN "<<setw(30)<<"CALCULATE RATE IN "<<endl; 
  
  cout<<"(1) ml/hr & tubing drop factor "<<setw(20)<<"drops/min"<<endl;
  
  cout<<"(2) mg/kg/hr & concentration in mg/ml"<<setw(10)<<"ml/hr"<<endl;
  
  cout<<"(3) QUIT"<<endl;
  
	int x;
	cout<<"Problem => ";
	cin>>x;
	
	return x;
}
	
int main ()
{
	cout<<"INTRAVENOUS RATE ASSISTANT"<<endl;
	int choice;
	float k,j,result1,result2 ,d ,l,m ;
	choice=getProblem ();
	
	while(choice!=3)
	{
	
	if(choice==1)
	{
	getRateDropFactor(k,j);
	result1=figDropsMIn(k,j);
	
	cout<<"the drop rate per minute is "<<ceil(result1)<<endl;
    }
	
	else if(choice==2)
	{
	
	getKgRateConc(d,l,m );
	result2=byWeight(d,l,m );
	
	cout<<"the rate in mililitres per hour is "<<ceil(result2)<<endl;
	
    }
	else 
	{
	cout<<"Please run the system again and choose a problem number between 1 and 3. \n " ;
	
	}
	choice=getProblem ();
        
    }

	
	cout<<"You have chosen to quit the program. \n "
        <<"Thank you for using our system. "<<endl;
     
	
    
	
	return 0;
}
  
