Help pls

Hello everyone, can someone please help me with my code I am trying to run. I am trying to find a solution on why this file is freezes when I run it.

According to the assignment the program is to

-initialize patientCount to 0
-read first ID and howMany from file
-while not end-of-file
*increment patientCount
*display ID
*use a count-controlled loop to read and sumup this patient’s howMany BP’s
*calculate and display average for patient
*read next ID and howMany from file
-display patientCount

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <string>
#include <conio.h>
#include <fstream>
using namespace std;

int main(){

    //Initialize Required Variables For Program
    int patientCount = 0;
    string id;
    string rHowMany; //String To Read From File
    int howMany = 0;
    int howManyCount = 0;
    int avg = 0;
    int avg2;
    string line;
    int number_lines = 0;
    ifstream reader ("data.txt"); //Open The Data File To Be Read From

    do{
        reader >> id;
        reader >> howMany;
        cout << "The Patient ID Is: " << id << endl;
        cout << "The Number Of Blood Pressure Record This Patient Has Is: " << howMany << endl;
        do{
            reader >> avg;
            avg = avg + avg;
        }
        while (reader != "\n");
        cin.clear();
        avg = avg / howMany;
        cout << "The Patient Average BP Reading Is: " << avg;
    }
    while (!EOF);
    return 0;
}


The data.txt file looks exactly like this
1
2
4567 4 180 140 170 150
5643 2 125 150




1st column is Patient ID
2nd column is How Many Tests the patient had
3rd column and beyond is all the blood pressure readings.

If anyone can help me out I greatly appericate that.
Last edited on
Topic archived. No new replies allowed.