Need help with Logic of the code

+1 Giorgio M · February 26, 2015
Okay I got the code working fine now but the logic isn't there.

What is happening is I have a .txt file in my project like this.

4567 4 180 140 170 150
4693 1 119
4690 5 200 120 135 136
4693 2 149 133
4783 3 133 123 140
4824 3 130 155 120
4833 2 119 186


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


What the trouble is that I am having is I can't add up the average per Patient ID. It isn't outputting correctly. Also how do I get more than one to output? Thanks

-Giorgio


#include
#include
#include
#include
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;
    string line;
    int number_lines = 0;
    ifstream reader ("data.txt"); //Open The Data File To Be Read From

    do
    {
        reader >> id;
        reader >> howMany;
        cout

Post a Reply

Replies

Oldest  Newest  Rating
+1 Giorgio M · February 26, 2015
uhhhhh for some reason the forums isn't letting me post the whole code. So sorry about that guys. :( We have a problem Bucky.
+1 Giorgio M · February 26, 2015
http://pastebin.com/G49nE47w
+1 Giorgio M · February 26, 2015
How do I calculate the average for the data? The issue I came across was how do I pull those blood pressure readings out of the text file and add them all up to divide them by my variable howMany.
+1 Giorgio M · February 26, 2015
Thank you it worked! I appericate the help!
  • 1

C++

107,007 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator