IUP Computer Science
COSC 110 Fall
05
Project #5
(Past COSC 110 Class)
(Due 18 Nov 05)
The file 110.txt contains information about
all the students who took COSC 110 during one semester a few years ago.
The form of a line in this file is
last-name, first-name
major class-year gpa
#-COSC-credits
That is, for each student, the file contains
their name (last-name, firstname), the student's major (as a 3- or 4-letter
designator), the student's year (1, 2, 3, or 4), the students overall grade
point average, and the number of credits of COSC courses the student had
before taking COSC 110. Here is a sample of a few lines from the
file.
Smith, Tater
COSC 2 3.45 9
Plug, Spark
MATH 1 1.91 3
Parker, Harriet
CHEM 3 2.53 6
Parker, Stanley
CRIM 1 1.86 3
Bumstead, Blondie
COSC 4 2.69 6
You are to write a C++ program that creates
a report about these students from COSC 110. The report needs to
show the following statistics and information first:
-
The number of students taking the course.
-
The average class year for all students (to
two decimal places).
-
The average GPA for all students (to two decimal
places)
-
The average number of COSC credits for all
students (to two decimal places)
-
A list of the major designators for the students
in COSC 110 - each major should have its designator listed once.
Then, for each major (except COSC) whose students
have a collective average GPA that is greater than the average GPA for
all students, list the major designator, the average GPA for students in
that major and the names and GPAs for all students in the major.
The names should appear as first-name last-name
that is, first name first and last name last with one space between (no
comma). The names and GPAs should be displayed in a nice columnated
format. For example, you will discover that Math majors have a higher
average GPA than the overall average GPA; you should display something
like this for the Math majors:
MATH majors, GPA=2.88
Norman Drabble
2.00
Broom Hilda
2.84
Marryin' Sam
3.69
Spark Plug
1.91
Julius Dithers
2.99
Wendy Welding
3.82
Your program is required to have at least
three functions, in addition to main. Each of these functions is
outlined below. You may include additional functions if you wish;
but you must have functions with the names specified that do each of the
following.
-
SetUpArrays This function
must be used to read the entire contents of the file, 110.txt, into arrays
which will be used throughout the rest of the program. You do not
know the number of students in the file; the function will have to determine
that number. You may assume that there are no more than 200 student
records in the file. Note: Your program is permitted to read
the file only once.
-
Average This
function must take an array of floating point values as one of its parameters
and calculate the average of the values.
-
SearchNAdd This function
must search through an array of strings for a specific string. If
the string that is sought is present in the array, no action is needed.
If the string is not present, the sought-for string should be added to
the array. The function will also have to update the number
of strings in the array as appropriate. You may assume that there
will never be more than 30 strings in the array.
These functions (and any others you may write)
may be either void or value-returning, depending on your preference and
what is appropriate for the task.
You are required to hand in a printout
of your well documented program and a printout of the report showing all
of the things listed above. In addition, you are required to submit
a copy of the .cpp file (named after yourself) to the handin folder on
the P: drive.
You can get a copy of the 110.txt file
from the I: drive or the P: drive.
On I:\jlwolfe\110\110.txt
On P:\courses\fall2005\COSC\COSC110\xxx\information\110.txt
where xxx is your section number