Creating a program that reads in student name and test score

Mar 19, 2012 at 5:53pm
I have looked through the forums and I did not find a topic with a program question similar to mine. I am having problems with setting up a program. The guidelines are:

The first line will contain the number of test scores for each student followed
by the number of students.

Each following line will contain a student record consisting of the student's
name (last name only, no space) followed by his test scores. No scores will be
missing.

Your program should calculate and report the average for each
student with that student's lowest test score being dropped.

I don't have much written, so far, but if I could get a little better idea of where I am going that would be much appreciated.

ifstream inData; // Opens text file
float stcount; // Student count
float testscore; // Student's test score
string studentname; // Student's last name read in
float sum = 0;
float average = 0;
int howmanyscores; // How many scores will be read in
int numnames; // How many student names will be read in

// Open text file
inData.open ( "lab6data.text" );

// Extract the number of last names and how many test scores being read
inData >> howmanyscores >> numnames >> endl;

// Initialize student count
stcount = 0

// Read in first student's name and test scores
inData >> studentname;

// Begin loop
while ( inData )
stcount ++;

inData >> studentname;

// Read and sum each student's test scores



// Average each student's test scores
if (counter != 0 )
average = sum / stcount;


// Output the student's last name and their average test score in columns
cout << " Last name Average Test Score " << endl;

I don't know about arrays or anything like that yet so I can't use that. I do believe this needs to be a nested loop type of program. I am not really sure how to make that work as well as having the program drop the lowest test score. Thank you in advance for any help.
Mar 20, 2012 at 12:28am
closed account (G854izwU)
Is this your homework?
Mar 20, 2012 at 2:17am
It is. I am not expecting an entire program written, just how to start working this program. My professor doesn't explain the material in a way I understand, so I am usually on my own for these programs.
Mar 20, 2012 at 4:05am
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
in >> n_scores >> n_students 

for ( s=0; s<n_students; ++s)
{
     in >> student_name 

     lowest_score = max_score_value
     score_total = 0 

     for ( sc=0; sc<n_scores; ++sc)
     {
          in >> current_score 
          if ( current_score < lowest_score)
               lowest_score = current_score 
          score_total += current_score 
     }

     average_score = (score_total-lowest_score) / n_scores-1 

     display average_score for student_name 
  }        


I'm sure it's not necessary to say that this is just pseudo code, but I said it anyway.
Mar 20, 2012 at 5:37am
Wow!!! Thank you!! I wasn'y expecting this much. I guess first thing in the morning I will be putting that to use and we will see from there. Thank you cire.
Topic archived. No new replies allowed.