I wanted to learn how to do some simple C++ programming so I bought this beginners book and software. Well the 2nd problem I'm suppose to do is a real bitch. The first one was easy but the 2nd one just confuses the hell out of me. It wants me to "loop" a program but hasn't explained how to do that...some book.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Problem Solving with C++
The Object of Programming
Problem #2
A hospital-supply company wants to market a program to assist with calculation of intravenous (IV) rates. Design and implement a program that prompts a clinician (typically a nurse) for dose as written by the physician, and the desired flow-rate format. The program must:
use a function to collect data and perform calculation for each problem (each type of calculation), returning the answer to its caller.
use a function that displays the menu, and returns the selected menu number to its caller.
output the answer rounded to the nearest whole number (NOT TRUNCATED).
continually re-prompt the user with the menu until the user enters 5 (Quit).
use local variables only.
be well commented/documented and use indentation appropriately.
use descriptive variable and function names.
display an error message if the user enters an invalid menu choice.
repeat until the user indicates that he/she wants to quit (menu item 5).
Here is the equation for problem 1 (drops per minute):
volume (ml) X drop factor (drops/ml)
----------------------------------------------
= drops / minute
time (min)
For more information on this "drop factor" equation, visit:
http://www.cybernurse.org.uk/nursing/i_ ... _rates.htm
The program should interact with the user as follows:
****************************************************
INTRAVENOUS RATE ASSISTANT
Enter the number of the problem you wish to solve.
GIVEN MEDICAL ORDER IN: CALCULATE RATE IN:
1) ml/hr and tubing drop factor drops/min
2) 1 L for n hrs ml/hr
3) mg/kg/hr and concentration in mg/ml ml/hr
4) units/hr and concentration in units/ml ml/hr
5) QUIT
Problem: 1
Enter rate in ml/hr: 150
Enter tubing's drop factor (drops/ml): 15
The drop rate per minute is 38.
Enter the number of the problem you wish to solve.
GIVEN MEDICAL ORDER IN: CALCULATE RATE IN:
1) ml/hr and tubing drop factor drops/min
2) 1 L for n hrs ml/hr
3) mg/kg/hr and concentration in mg/ml ml/hr
4) units/hr and concentration in units/ml ml/hr
5) QUIT
Problem: 2
Enter number of hours: 8
The rate in milliliters per hour is 125.
Enter the number of the problem you wish to solve.
GIVEN MEDICAL ORDER IN: CALCULATE RATE IN:
1) ml/hr and tubing drop factor drops/min
2) 1 L for n hrs ml/hr
3) mg/kg/hr and concentration in mg/ml ml/hr
4) units/hr and concentration in units/ml ml/hr
5) QUIT
Problem: 3
Enter rate in mg/kg/hr: 0.6
Enter patient weight in kg: 70
Enter concentration in mg/ml: 1
The rate in milliliters per hour is 42.
Enter the number of the problem you wish to solve.
GIVEN MEDICAL ORDER IN: CALCULATE RATE IN:
1) ml/hr and tubing drop factor drops/min
2) 1 L for n hrs ml/hr
3) mg/kg/hr and concentration in mg/ml ml/hr
4) units/hr and concentration in units/ml ml/hr
5) QUIT
Problem: 4
Enter rate in units/hr: 1000
Enter concentration in units/ml: 25
The rate in milliliters per hour is 40.
Enter the number of the problem you wish to solve.
GIVEN MEDICAL ORDER IN: CALCULATE RATE IN:
1) ml/hr and tubing drop factor drops/min
2) 1 L for n hrs ml/hr
3) mg/kg/hr and concentration in mg/ml ml/hr
4) units/hr and concentration in units/ml ml/hr
5) QUIT
Problem: 5
Goodbye...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I didn't buy the solution manual for this book because I already spent a crap load of money for the book and software. It does give me this as a starting point but its a little to complicated. I understand parts of it but not all of it. Can anybody tell me what to do next or just solve this problem so I can see what you did? I've been trying to figure it out for days!!!! Bout to throw this programming crap away.
#include <iostream>
using namespace std;
int main (void)
int task = 0;
double rate = 0.0;
task = getProblem( );
if (task == 1)
else if (task == 2)
int getProblem (void);
double calcDropsPerMinute (void);
double litersToMlPerHour (void);
double calcRateFromWeight (void);
double calcRateFromUnits (void);
void displayRate (double rate, int task);
int main (void)
{
cout << "INTRAVENOUS RATE ASSISTANT \n\n";
double rate = 0.0; //Will contain the calculated rate
int task = 0; //Will contain the users menu response
bool done = false; //Flag used to tell when user quits
do
{
task = getProblem( );
if (task == 1)
rate = calcDropsPerMinute( );
else if (task == 2)
rate = litersToMlPerHour( );
else if (task == 3)
rate = calcRateFromWeight( );
else if (task == 4)
rate = calcRateFromUnits( );
else if (task == 5)
done = true;
if (!done)
displayRate(rate, task);
}while (!done);
cout << "Goodbye.\n";
return 0;
}