Hi I need help with this program. When I run this program, it will not print out the correct kilograms which always displays 0. Please help

#include <iostream>
#include <istream>
#include <iomanip>
#include <vector>



using std::vector;
using namespace std;
using std::endl;
using std::setw;





struct PatientInfo {
    string name;
    double weight;
    int amtFluid;
};


// --------------------------------------------------------------
static inline std::string& ltrim(std::string& s)
{
    size_t i;
    for (i = 0; i < s.length() && std::isspace(s[i]); i++)
    {
        //nothing
    }

    s.erase(0,i);

    return s;
}

// --------------------------------------------------------------
static inline std::string& rtrim(std::string& s)
{
    size_t i;
    for (i = s.length()-1; i >= 0 && std::isspace(s[i]); i--)
    {
        //nothing
    }

    if (i < s.length())
    {
        s.erase(i+1,s.length()-i);
    }

    return s;
}

// --------------------------------------------------------------
static inline std::string& trim(std::string& s)
{
    return ltrim(rtrim(s));
}



void processIV(istream &input, ostream &output);
PatientInfo readPatientInfo(istream &input, ostream &output);
void printResults(ostream &output, PatientInfo patient);




//TODO add any constants you need (and you will want some!)

const double CONVERT_TO_KILOGRAMS = 2.2;
const double CONVERT_TO_LITERS = 1000;
//end



//TODO add your function declarations
double readWeight (istream &input, ostream &output);
string readName (istream &input , ostream &output);
double convertLbToKg (double weight);
double convertMLToL (int milliters);
int getFluidsForInfant (double kilograms);
int getFluidsForToddler (double kilograms);
int getFluidsForChild (double kilograms);
void printResult(ostream &output, string name, double kilograms, int milliters);



//end



//TODO add your function definitions


// Promptthe  user to enter patient's weight and 
// stores and returns that value in weight
double readWeight (istream &input, ostream &output)

{
    double weight;
    output << "Enter patient's weight in pounds" << endl;
    input >> weight;

        return weight;
}

//Prompt the user to enter patient's name and stores and returns
// that value in name
string readName(istream &input, ostream &output)

{
    string name;
    output << "Enter patient's name:" << endl;
        getline(cin,name);

    return name;
}


// Converts the patient's weight to kilograms
double convertLbToKg (double weight ){


    double kilograms = weight / CONVERT_TO_KILOGRAMS;

    return kilograms;
}

// Converts milliters to liters
double convertMLToL (int milliters){


    double liters = milliters/CONVERT_TO_LITERS;

    return liters;
}


int getFluidsForInfant (double kilograms){



        int milliters = static_cast<int>(kilograms * 100);

        return milliters;
}
int getFluidsForToddler (double kilograms){


        int milliters = static_cast<int>(1000+(50*(kilograms -10)));


        return milliters;
}
int getFluidsForChild (double kilograms){



     int milliters = static_cast<int>(1500+(20*(kilograms - 20)));

    return milliters;
 }

void printResult(ostream &output, string name, double weight, int milliters){

    double liters = convertMLToL(milliters);
    output.setf ( ios::left);
    output << setw(20) << name;
    output.setf ( ios::right,ios::fixed);
    output << setprecision( 2 ) << weight<< "kg" << setw(8) << "" << milliters << "mL" << setw(8) << "" << liters << "L" << endl;

}

//end






/**
 * @brief Reads in a single patient's information.
 *
 * Reads in a patient's name and weight and then calculates the amount of
 * fluid (in mL) that the person needs.  If the patients name is blank, the
 * function exits.
 *
 * @param input input stream to read from.
 * @param output stream to send prompts to.
 *
 * @return a PatientInfo struct with the patient's name, weight, and amout of
 *  fluids needed.  A name of "" indicates that there is no more data.
 *
 */

PatientInfo readPatientInfo(istream &input, ostream &output){
    PatientInfo patient;
    string patName = "";
    double weightInKg = 0.0;
    int amtFluidInML = 0.0;


    patName = readName(input, output);


    //TODO Read the patient's name by calling readName and storing the
    //result in patName.



    //end

    if (trim(patName) != "") {

        //TODO Read the patient's weight and then convert it to kilograms
        //You will need to call both the readWeight function and the
        //convertLbToKg function.  You may want to declare a variable to
        //hold the value read in before it is converted to kilograms.

        int weight = readWeight(input, output);
       double weightInKg = convertLbToKg(weight);


        //end


        if (weightInKg >= 0 && weightInKg <= 10) {


            //TODO Calculate the amount of fluids needed for an infant
            //Call the getFluidsForInfant function and pass it the patient's
            //weight in kilograms. Store the result in amtFluidInML.
               amtFluidInML = getFluidsForInfant(weightInKg);



            //end
        }
        else {
            if (weightInKg <= 20) {
                //TODO Calculate the amount of fluids needed for a toddle
                //Call the getFluidsForToddler function and pass it the patient's
                //weight in kilograms. Store the result in amtFluidInML.

                amtFluidInML = getFluidsForToddler(weightInKg);


                //end
            }
            else {
                if (weightInKg <= 70) {
                    //TODO calculateCalculate the amount of fluids needed for a child
                    //Call the getFluidsForChild function and pass it the patient's
                    //weight in kilograms. Store the result in amtFluidInML.


                   amtFluidInML = getFluidsForChild(weightInKg);


                    //end
                }
                else {
                    amtFluidInML = 2500;
                }
            }
        }
        //clear input to the end of the line
        input.ignore(10000, '\n');
    }


    patient.name = trim(patName);
    patient.weight = weightInKg;
    patient.amtFluid = amtFluidInML;
    return patient;
}

/**
 * @brief Writes a single patient's information.
 *
 * Writes a single patient's information to the output as a row in a table.
 *
 * @param output output stream to write to
 * @param patient collection of patient information
 *
 */
void printResults(ostream& output, PatientInfo patient) {
    string name = patient.name;
    double weight = patient.weight;
    int amtFluid = patient.amtFluid;

    //TODO Call your printResultMethod with the name, weight, and amtFluid
    //variables.

        printResult(output, name, weight, amtFluid);


    //end
}




/**
 * @brief Reads in a list of patient information and displays each patient's
 *  IV fluid requirements.
 *
 * Reads in the patient's name and weight and then displays the patient's IV
 * fluid requirements.  This continues until a blank name is entered for the
 * patient.
 *
 * @param input Input stream to read from
 * @param otuput Output stream to read from
 *
 */
void processIV(istream &input, ostream &output) {
    vector<PatientInfo> patients;
    PatientInfo patient;


    //read in the patients
    patient = readPatientInfo(input, output);
    while (patient.name != "") {
        patients.push_back(patient);
        patient = readPatientInfo(input, output);
    }

    //print out vector
    for (vector<PatientInfo>::iterator iter = patients.begin();
            iter !=  patients.end(); ++iter) {
        //print results
        output << left << setw(20) << "Name" << setw(10) << "Weight"
                << "IV Fluids" << endl;
        printResults(output, *iter);
    }

}


 * @brief Reads in a list of patient information and displays each patient's
 *  IV fluid requirements.
 *
 * Reads in the patient's name and weight and then displays the patient's IV
 * fluid requirements.  This continues until a blank name is entered for the
 * patient.
 *
 * @return an error value on an error; 0 otherwise
 *
 */
int main() {

    processIV(cin, cout);

    return 0;
}

Change line 223 from
dobule weightInKg = convertLbToKg(weight);
to
weightInKg = convertLbToKg(weight);
You defined weightInKg at line 201 and then again at line 223 but then you used it in 275. But were you set it at line 223 is a different scope then the one defined at 201.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.