SYCS-135 INTRODUCTION TO PROGRAMMING

 

ASSIGNMENT 7

 

Due Date: November 2 , 1999

 

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:

 

AI98F��� CW�� 5��� A� 3��� B� 4��� A� 4��� A� 6

� C ��������� �3

AI98F������ 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 and at least one value returning function and one function with a reference parameter.

 

Output:� Write the heading:� �Professor Algol�s Artificial Intelligence Class - Fall 1999�.� 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 - Fall 1999

***********************************************************

�� 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 (but your maximum assignment grade is still 20).� Tabulated-format would look like:

 

***********************************************************

�� Professor Algol�s Artificial Intelligence Class - Fall 1999

***********************************************************

�� 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 November 2nd 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 November 1st, 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 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

 

All C++ program assignments are now to be submitted electronically.� Your program will be run using the instructors� data.� For Assignment 7, name your C++ program file assign7.c 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 Nov. 1, 1999.� All assignments are automatically time-stamped and no late assignments will be accepted.� If before the deadline, 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.

��������������������������������������������������������������������������������������������������������������������