#include <iostream>
#include <cmath>
using namespace std;

double getProblem();
void getRateDropfactor(int mlh, int dml, double &drop);
int figDropsMin (double fix);
void getKgRateConc(int &a, int &b, double &c);
int byWeight (int x, int y, double z);



int main()
{
	int b, c, d, e, f, g;
	double a, x, y, z, DR, p;
	
	do
	{
		cout << endl << "INTRAVENOUS RATE ASSISTANT" << endl << endl
		<< "Enter the number of the problem you wish to solve." << endl;
		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 << endl;
	
	
		a=getProblem();
		cout << endl;
	
		while(a != 1 && a != 2 && a != 3)
		{
			cout << "Please run the system again and choose a problem number between 1 and 3" << endl;
			a=getProblem();
		}
	
		if(a == 1)
		{
			cout << "Enter rate in ml/hr" << endl;
			cin >> b;
			cout << "Enter tubing's drop factor (drops/ml)" << endl;
			cin >> c;
			getRateDropfactor(b, c, DR);
			d=figDropsMin (DR);
			cout << "The drop rate per minute is " << d << endl;
		
		}
		else if(a == 2)
		{
			getKgRateConc(e, f, p);
			g = byWeight (e, f , p);
			cout << "The rate in millilitres per hour is " << g << endl;
		}
	}
	while (a == 1 || a == 2);
	
	cout << "You have chosen to quit the program." << endl;
	cout << "Thank you for using our system." << endl;

	
	
	
	system("pause");
	return 0;
}

double getProblem()
{
	double s;
	cin >> s;
	return s;
}

void getRateDropfactor(int mlh, int dml, double &drop)
{
	drop = static_cast<double>(mlh) * dml / 60;
}

int figDropsMin (double fix)
{
	int z;
	z = ceil(fix);
	return z;
}

void getKgRateConc(int &a, int &b, double &c)
{
	cout << "Enter rate in mg/hr " << endl;
	cin >> c;
	cout << "Enter patient weight in kg " << endl;
	cin >> a;
	cout << "Enter concentration in mg/ml " << endl;
	cin >> b;
}

int byWeight (int x, int y, double z)
{
	int a;
	double F, b;
	F = x * y * z;
	a = F;
	b = F - a;
	if(b >= 0.5)
	{
		a += 1;
		return a;
	}
	else
	{
		return a;
	}
}
