Question: In this assignment you are to write a program that reads in scores for students taking a class from a data file, calculates and displays

In this assignment you are to write a program that reads in scores for students taking a class from a data file, calculates and displays student information (name & gender), the grade (percentage and letter) for each student, and then displays the average percentages for the class.

Your program should prompt the user for the name of the data file. Your program should support filenames up to FILENAME_LEN (explained below) characters for the data file name. It also needs to verify that the input file opened successfully. An error message should be displayed and the program terminates if the file open fails. The format for the data file is as follows:

- The first line of the data file contains three whole numbers: the number of students in the class, the number of scores for each student, and the total points possible.

- Each consecutive line in the file contain a student's name ( one word, a maximum of MAX_NAME_LEN characters long), gender (a single character 'M' or 'F'), and scores. There will be one line for each student. The number of students and the number of scores per student is indicated in the first line of the data file.

Here is a sample data file:

7 6 600

CARMEN F 95 91 92 88 100 90

carson M 91 85 88 89 82 91

RUby F 83 72 75 81 77 91

cRAMER M 79 82 85 84 80 81

DanA F 88 84 86 89 93 92

snorKLE M 70 68 75 63 66 69

Carl M 80 78 85 73 76 79

This data file indicates there are 7 students. Each student has 6 scores, and the points possible is 600.

The output of the program should be a table with column headers (including separation lines), and data rows that include the following for each student:

- Name, converted to uppercase for the first character of the name and lowercase for all subsequent characters

- Gender, displayed as "Male" or "Female"

- Overall percentage, calulated by dividing the sum of the student's scores by the points possible

- Letter grade (A, B, C, D, F) based on a 10%

scale:

90's and above is an A

80's is a B

70's is a C

60's is a D

Anything below 60 is an F

Below the table the following should be displayed:

- # of male students, % of students that are male

- # of female students, % of students that are female

- average percentage for male students

- average percentage for female students

- average percentage for the entire class

The output for the program should look very

similar to this:

Enter data file name: grades.dat

Student Gender Percentage Grade

--------------- ------ ---------- -----

Carmen Female 92.7% A

Carson Male 87.7% B

Ruby Female 79.8% C

Cramer Male 81.8% B

Dana Female 88.7% B

Snorkle Male 68.5% D

Carl Male 78.5% C

# (%) Males: 4 (57.1%)

# (%) Females: 3 (42.9%)

Male average: 79.1%

Female average: 87.1%

Class average: 82.5%

Your source code file for this assignment should include the following two declarations at the top of your file after your #include statements and before your functions:

const int FILENAME_LEN = 32;

const int MAX_NAME_LEN = 16;

FILENAME_LEN should be used any place a maximum length for a filename is needed.

MAX_NAME_LEN should be used any place where a maximum length for a student name string is needed.

I will specifically be looking for the following when it comes to the output your program:

- Nice, clean column formatting, matching my sample output above as closely as possible

- Left justification for the name. You can assume a name won't exceed MAX_NAME_LEN characters.

- The gender should be displayed as "Male" or "Female" (not 'M' or 'F') and should be left justified

- The percentage column in the table should be right justified

- All percentage values should displayed with one one place past the decimal and include the percent sign.

Other requirements:

Implement your programs using functions that pass in parameters and return values.

Your program should be flexible enough to work with different data files, not just the grades.dat sample file I've provided.

Your program should not have any limitations for the number of students or the number of scores per students. If you can't figure out how to accomplish this, ask for help with designing your program.

You can assume that there are no errors in the contents of the data file. It will follow the rules described above.

You are NOT allowed to use the std:string datatype from the header. User character arrays for the filename and student names. The size of these arrays should be based on the FILENAME_LEN and MAX_NAME_LEN constants provided above.

*Any help is appreciated *

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!