Site hosted by Angelfire.com: Build your free website today!

Program 32K. Dzwonkiewicz

C++

 

 

This program will keep track of data in a file for a student (call it stud.dat)

 

It will load the data into a regular array and print the personal information and current test scores and the average of these scores (as below)

 

After all scores are displayed, ask if a new score needs to be added.  Add the new score and resave the file (during each run it may or may not add a new score)

 

Sample Run…

 

Student Name: Jean Lafitte

Current Grade: 11

Sex: Male

Address: 8636 Privateer Lane, Galveston, Texas

 

Tests: 8

{ 65, 75, 70, 90, 50, 72, 68, 70}   AVERAGE: 70.00   Grade: C

 

Enter a new test? (Y/N)    y

Please enter test_ 88

 

Is the new test 88 is correct? (Y/N) y

DONE

 

 

 

(You must create your own file for this one)

 

Hints: To do the array…

            int test[81];  //to declare it as an array with the max location test[80]

 

(to get from the file) remember with arrays we will always use location 0 as the first subscript

                c = 0;

                dzwon>>test[c];         //priming read

                while(dzwon)        //tests stream status

                {

                  c++;                      //increment location

                  dzwon>>test[c];         //does next read from file

                }

your loops can now go for (x = 0; x < c; x++)