SYCS-135
INTRODUCTORY PROGRAMMING
�ASSIGNMENT 7
Due March. 8, 2001
Problem: You have been asked to calculate the GPA�s and
determine the Valedictorian of the students in Professor Algol�s artificial
intelligence class. Professor Algol is somewhat absent-minded and doesn�t know
exactly how many students are registered, but she is quite sure that her
teaching assistant has typed all the student records into a file for you. Since
her student assistant was unfamiliar with programming languages, he typed in
the data with lots of additional white space (spaces, tabs and new lines) than
really necessary (of course he did not insert any white space within data
items).
Input: the input data stream format for each student is:
type of datum������������ meaning
5 characters����������������������������� class id (includes
year and semester)
2 characters����������������������������� student id
integer N��������������������������������� number of
pairs of class grades & credit
����������������������������������������������� hours
following, N<=6
character��������������������������������� letter grade
for class-1
integer������������������������������������� number of
credit hours for class-1
character��������������������������������� letter grade
for class-2
integer������������������������������������� number of
credit hours for class-2
...�������������������������������������������� ...
integer������������������������������������� letter
grade for class-N
integer������������������������������������� number of
credit hours for class-N
Create an external file named grades.txt.
Name your input file readit and include the following statement in your
program: readit.open("grades.txt");.
Use the following input data for your first
two students then make up at least 2 more sets of student data:
AI00S CW 5�� A 3����� B
4������ A 4����� A 6
C ������������������� �3
AI00S HK 6��������������� C 2����� C 3����������������� B 4������ D 4����� D
2����� C ������� 3
(add additional sets of data here)
Formulae required in computation:
Conversion of letter grades to quality
points: A = 4, B = 3, C = 2, D = 1, F = 0.
GPA = (sum of (grade * credit hours) / sum
of credit hours ) rounded to one decimal place.
Valedictorian is the student with the
highest GPA score.
Special requirements: use a nested while loop.
Output: Write the heading: "Professor Algol�s Artificial
Intelligence Class - Spring 2001". Then write out a neat table of student
id�s, pairs of grades and credit hours, and GPA�s. After you have written out
all the student�s information, write out the id and GPA of the Valedictorian.
If you only used the 2 sets of given data,
well-formatted output would be:
***********************************************************
Professor
Algol�s Artificial Intelligence Class - Spring 2001
***********************************************************
Name������������� Grades/credit hours, GPA
�����������������������������������������������������������������������������������������������������������������������������������������������
CW����������������� A/3 B/4 A/4 A/6 C/3 GPA = 3.5
HK����������������� C/2 C/3 B/4 D/4 D/2 C/3 GPA =
1.9
CW is the
Valedictorian with a GPA of 3.5
***********************************************************
Extra Credit: You can earn up to 4 extra points by formatting your
output in tabular form so that each student�s GPA is always written out in the
same columns (so your maximum assignment grade is 24). Tabulated-format would
look like:
***********************************************************
Professor
Algol�s Artificial Intelligence Class - Spring 2001
***********************************************************
Name������������� Grades/credit hours�������������������������������������������������� GPA
�����������������������������������������������������������������������������������������������������������������������������������������������
CW����������������� A/3 ���� B/4 ���� A/4 ���� A/6����� C/3����������������������������� 3.5
HK����������������� C/2 ���� C/3 ���� B/4����� D/4 ��� D/2
���� C/3����������������� 1.9
CW is the
Valedictorian with a GPA of 3.5
***********************************************************
ASSIGNMENT SUBMISSION: On March 6th� hand in a hard copy of your algorithm in pseudocode, your test
oracle and desk-checking calculations, your C++ program compilation listing,
and your output obtained from running your program with the several sets of
data. You will also submit your program electronically on March 8th,
see below.
Pseudocode: A 1-page description of your algorithm in pseudocode.
Test Oracle: Choose several sets of data in addition to the
specified sets described above. For each set, use your algorithm to calculate
by hand (you can use a calculator) the answer to the problem and write down
this answer.
Program Output: First print out the your name, course number and
title, assignment number, and date, followed by a description of the problem.
Print the input
data with appropriate headings, followed by the answer to the problem as
specified above. GPA�s should be rounded printed to one decimal place.
Program Documentation: At the top of your source code as a comment, include
your name, course number and title, assignment number, and date, followed by a description
of the problem. Include comments as necessary throughout your program to
illustrate the algorithm, logic of flow, meaning of variables etc. Follow the
style guidelines described in class.
---------------------------------------------------------
Electronic Submission - SCS
Laboratory
All C++ program assignments are now to be submitted electronically. For
Assignment 7, name your C++ program file assign7� and use the following command to submit your program:
$ Keeling assign7.c ������������������������������
The assignment is to be submitted electronically no later than 10:00pm on Mar. 8,
2001. The receiving file will be closed at 10:00pm and no late assignments will
be accepted. If before the due dates, you send in a version of your assignment,
having already sent in an earlier version, the later version will automatically
replace the earlier version in the assignment file.
---------------------------------------------------------
Electronic Submission � via E-mail
If you do not have an
SCS account, your program can be submitted via E mail. If you select this mode
of submission then you must make sure that you make the subject of your message
�assign7.c � and use the following E mail addresses
����������� [email protected]
�����������
The
body of the message should be your source code listing with the program�s
output as comments.