#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

float byWeight(float r2, float w2, float c2)
{
	float mlhr;
	mlhr = r2 * w2 * c2;
	return static_cast<int>(round(mlhr));
}

float figDropsMin(float r, float d)
{
	float dropmin;
	dropmin = d * r  / 60;
	return ceil(dropmin);
	
}

void getRateDropFactor(int prog)
{
	float rate1, drop;
	cout << "Problem => " << prog << endl;
	cout << "Enter Rate in ml/hr\t: ";
	cin >> rate1;
	cout << endl << "Enter tubing's drop factor\t: ";
	cin >> drop;
	cout << endl << "Drop Rate Per Minute\t: " << figDropsMin(rate1,drop);
	
}

void getKgRateConc(int prog)
{
	float rate2, weight, conc;
	cout << "Problem => " << prog << endl;
	cout << "Enter Rate in mg/hr\t: ";
	cin >> rate2;
	cout << endl << "Enter patient's weight in kg\t: ";
	cin >> weight;
	cout << endl << "Enter Concentration in mg/ml\t: ";
	cin >> conc;
	cout << endl << "The rate in millimeters per hour\t: " << byWeight(rate2,weight,conc);
	
}

int getProblem()
{
	int prog;
	cout << "Please enter the number of problem you wish to solve" << endl;
	cout << "[1] ml/hr & tubing drop factor \t\t drops/min\n[2] mg/kg/hr & concentration in mg/ml \t\t ml/hr\n";
	cout << "[3] QUIT " << endl;
	
	cout << "Please Enter A Program Code	: ";
	cin >> prog;
	return prog;
}



int main()
{
	int prog;
	
	prog = getProblem();
		while (prog > 3)
	{
		cout << "Please choose a code from 1 to 3 only" << endl;
		cout << "Please Enter A Program Code	: ";
		cin >> prog;
	}
	
	while (prog ==1)
	{
		getRateDropFactor(prog);
		cout << "\nPlease Enter A Program Code	: ";
		cin >> prog;
	}
	
	while (prog == 2)
	{
		getKgRateConc(prog);
		cout << "\nPlease Enter A Program Code	: ";
		cin >> prog;
	}
	
	cout << "\nYou have chosen to quit" << endl;
	cout << "Thank you";

	return 0;
	
}
