I am using Microsoft Visual C++ to write a program, i am trying to

As records secretary for Cougar High School, you have been asked by the principal to prepare a report on the grades of some of the school's top athletes. Specifically, you must print each of the athlete's average letter grades based on their scores from three academic courses. Input will be taken from the file stufile.txt, which is organized as follows: Each athlete in the file has four lines of information recorded - name (at most 20 characters including the comma and white space), student ID (SS#), class rank (1=Freshman, 2=Sophomore, 3=Junior, 4=Senior), and the three scores. Information for at most 15 athletes is stored in the file, but the first line of the file contains an integer showing the exact number of athletes.

Use class data type as data representation of a student record. Then, design member functions to do the statistics, reporting, etc. For each student, your program should calculate the average of the 3 scores and determine the letter grade based on the average (A - 90 or above, B - between 80 and 90, C - between 70 and 80, D - between 60 and 70, and F - below 60). also, your program must find the students with the highest and the lowest averages.

Your program must read in student information from "stufile.txt". You can create the file and copy the examples in the following and save them in the file. Or, you can create your own file using the format specified above.

You can assume that all scores are integers from 0 to 100. Output from this program should be printed out on the screen. The output of the program should include the echo-print of all the records that are read from the input file and the statistical data specified as follows. When printing each student record, the column of student ID numbers should be aligned at least one space beyond the maximum name length, the column of class ranks should be aligned at least one space beyond the column of student IDs, and the column of grades should be aligned at least one space beyond the column of class ranks. Echo-printing of the students records must begin with a heading (see the example in the following). Students ranks must be printed as "Freshman", "Sophomore", "Junior", or "Senior", instead of a number. In the end of the output, the name of the students with the highest average and the lowest average must be printed with proper labeling

For each student record, do i need to create a new txt file? Also, would i be able to just create an array to create the program?

I created a header file :

#include <string>
#include <fstream>

#define MAX_NUM_STUDENTS 15
#define MAX_LEN_NAME 20
#define LEN_SSN 10

enum Rank {Freshment, Sofomore, Junior, Senior};
enum letGrade {A, B, C, D, F};

class StuRecord {
public:
  void ReadRecord(ifstream& inputFile);
    // Precondition:
    //   Input stream inputfile is opened and the file is not empty.
    // Postcondition:
    //   The next student record in the input file is read and stored
    //   in this object. The rank is save as a value of the enumeration 
    //   type "letGrade" according to the read-in numeric rank number.
  void Average();
    // Precondition:
    //   The 3 grades (grade1, grade2, and grade3) are assigned.
    // Postcondition:
    //   Find the average of the 3 grades.
  void LetterGrade();
    // Precondition:
    //   The average is assigned.
    // Postcondition:
    //   Determine the letter grade according to the average.
  void Print() const;
    // Precondition:
    //   name, ssn, rank, and grade are assigned.
    // Postcondition:
    //   Print out the student record.
  StuRecord();
    // Default constructor.

private:
  string name;
  string ssn;
  Rank  rank;
  letGrade grade;
  int  grade1, grade2, grade3, average;
};

And a source file...which i am not sure what to do from this point forward =(

#include "project 1.h"
#include <iostream>
#include <fstream>

using namespace std;




  enum Rank {Freshment, Sofomore, Junior, Senior};
  enum letGrade {A, B, C, D, F};
  struct StuRecord
  {
      string name;
      string ssn;
      Rank  rank;
      letGrade grade;
      int  grade1, grade2, grade3, average;
  };

Recommended Answers

All 2 Replies

You should edit your post and put your code between code tags (don't put the spaces I used between [ and ])
[ code=cplusplus ]
your code here
[ /code ]

You will have just one text file, containing information on multiple students. Your data in the program should be stored in an array of the StuRecord objects.

I would store the three grades in the StuRecord as an array, rather than three separate variables. Not that it's crucial here, but you should develop habit of storing groups of related items that way - makes it easier to expand the scope of the problem if you use an array a loop through it to process.

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.