CS 162 Fall 2001                                Assignment 6 –Vectors and Generic FunctionsUsing an existing class                100 points

 

Assigned: 10/15/2001

Due: 10/26/2001 at the start of class.

Pre-Lab (Do Before Lab): Bring an empty (or nearly empty) disk. Plan out steps needed for program.

Pairs: You may work in pairs if you want. Note, during the course of the semester, you cannot pair with any one person more than twice. If you work in a pair, turn in ONE copy that is the work of both of you, with both of your names on it.  Each member of the pair will receive the same grade for that lab.  In such a partnership, students must share as equally as possible the work and learning.  Working together with truly shared effort and learning can be a positive experience. However, simply giving/receiving code from someone defeats the learning process. If substantial parts of a program are taken from non-partners, that is plagiarism. The copier and copyee will each receive a zero.

Main Assignment:

                A simplified Student class has been provided (student.h and student.cpp under Review on my WWW page). Create a client program, as illustrated below. The program should ask for input on multiple students (until user has entered all that they desire), validate each student as they are entered (other than strings such as first name, all data should be validated), and put each student into a vector appropriate to their year in school (freshman, sophomore, etc).  After all students have been entered, sort each of the 4 vectors by GPA from high to low, and display each vector in order in turn, as illustrated below. 

Details:

1)       If you change student.h and/or student.cpp,  make sure you hand them in as well. (I don’t think you should have to – I don’t think you should even have to look at student.cpp)

2)       You can get the random student ID numbers using the default constructor.

Hand-in:

    1) Listing of the program

 2) Disk with your .cpp file and your working .exe file. NAME YOUR PROGRAM FILE yourlastname6.cpp; Name your project yourlastname6 so that the executable will be yourlastname6.exe. If you are working in pairs, use both last names (e.g. redmondsmith6.cpp)

Miscellaneous:

1) If you have any questions about what should be done, please ask!!

2) MAKE SURE YOUR PROGRAM WORKS! (i.e. more than just removing compile errors). Test it more than once - I will!

3)       Remember: Indentation, meaningful variable names, symbolic constants, and meaningful comments. Weaknesses in any of these could result in points off. Also make sure you put YOUR NAME(s), section, and e-mail address in comments at the beginning of the program.

4)       The below interaction does not show all of the input, in order to make the assignment hand out a reasonable length. It also has some errors in string fields (e.g. major) (can’t catch those easily)..

Sample Interaction:

Please enter information for the next student

Please enter first name: Joan

Please enter last name: Jett

Please enter year in school using numbers (1 - Fr; 2 - So; 3 - Jr; 4 - Sr): 1

Please enter major: RR

Please enter number of credits earned so far 7

Please enter number of grade points earned so far 24

Please enter current balance due 200

Are there more students to enter (Y / N): y

Please enter information for the next student

Please enter first name: Mark

Please enter last name: Knopfler

Please enter year in school using numbers (1 - Fr; 2 - So; 3 - Jr; 4 - Sr): 4

Please enter major: Music

Please enter number of credits earned so far 112

Please enter number of grade points earned so far 345.5

Please enter current balance due 100

Are there more students to enter (Y / N): y

Please enter information for the next student

Please enter first name: Joe

Please enter last name: Strummer

Please enter year in school using numbers (1 - Fr; 2 - So; 3 - Jr; 4 - Sr): 3

Please enter major: Business

Please enter number of credits earned so far 68.5

Please enter number of grade points earned so far 653.9

invalid answer must be between 0 and 600 - please re-enter

Please enter number of grade points earned so far 543.5

Sorry that number of grade points is impossible for the number of credits earned

it should not be more than 274

Please enter number of grade points earned so far 254

Please enter current balance due 12.5

Are there more students to enter (Y / N): y

Please enter information for the next student

Please enter first name: Rick

Please enter last name: Ocasek

Please enter year in school using numbers (1 - Fr; 2 - So; 3 - Jr; 4 - Sr): 2

Please enter major: RR

Please enter number of credits earned so far 2

Please enter number of grade points earned so far 8

Please enter current balance due 0

Are there more students to enter (Y / N): y

Please enter information for the next student

Please enter first name: Eddie

Please enter last name: Vetter

Please enter year in school using numbers (1 - Fr; 2 - So; 3 - Jr; 4 - Sr): 2

Please enter major: 35

Please enter number of credits earned so far 35

Please enter number of grade points earned so far 74.3

Please enter current balance due 0

Are there more students to enter (Y / N): y

Please enter information for the next student

Please enter first name: Joe

Please enter last name: Jackson

Please enter year in school using numbers (1 - Fr; 2 - So; 3 - Jr; 4 - Sr): 4

Please enter major: Biology

Please enter number of credits earned so far 99

Please enter number of grade points earned so far 345.6

Please enter current balance due 10

Are there more students to enter (Y / N): y

Please enter information for the next student

Please enter first name: Elvis

Please enter last name: Costello

Please enter year in school using numbers (1 - Fr; 2 - So; 3 - Jr; 4 - Sr): 1

Please enter major: Music

Please enter number of credits earned so far 12

Please enter number of grade points earned so far 39

Please enter current balance due 0

Are there more students to enter (Y / N): y

Please enter information for the next student

Please enter first name: Tom

Please enter last name: Stoltz

Please enter year in school using numbers (1 - Fr; 2 - So; 3 - Jr; 4 - Sr): 4

Please enter major: EE

Please enter number of credits earned so far 103

Please enter number of grade points earned so far 345

Please enter current balance due 0

Are there more students to enter (Y / N): y

Please enter information for the next student

Please enter first name: Ricky

Please enter last name: Barrett

Please enter year in school using numbers (1 - Fr; 2 - So; 3 - Jr; 4 - Sr): 5

invalid answer - please re-enter

Please enter year in school using numbers (1 - Fr; 2 - So; 3 - Jr; 4 - Sr): 1

Please enter major: Music

Please enter number of credits earned so far 18

Please enter number of grade points earned so far 58.5

Please enter current balance due 0

Are there more students to enter (Y / N): y

Please enter information for the next student

Please enter first name: Robert

Please enter last name: Palmer

Please enter year in school using numbers (1 - Fr; 2 - So; 3 - Jr; 4 - Sr): 2

Please enter major: 56

Please enter number of credits earned so far 234

invalid answer must be between 0 and 150 - please re-enter

Please enter number of credits earned so far 56

Please enter number of grade points earned so far 234

Sorry that number of grade points is impossible for the number of credits earned

it should not be more than 224

Please enter number of grade points earned so far 201

Please enter current balance due 1290

Are there more students to enter (Y / N): y

       ……

Are there more students to enter (Y / N): n

Freshmen:

3411 : Adam : Clayton : 0 : PS : 17 : 68 : 4 : 0 :

1740 : Joan : Jett : 0 : RR : 7 : 24 : 3.42857 : 200 :

8291 : Mike : Mills : 0 : 29 : 29 : 98 : 3.37931 : 2 :

6066 : Marshall : Crenshall : 0 : Drama : 24 : 81 : 3.375 : 0 :

1892 : Ricky : Barrett : 0 : Music : 18 : 58.5 : 3.25 : 0 :

2216 : Elvis : Costello : 0 : Music : 12 : 39 : 3.25 : 0 :

3615 : Kurt : Cobain : 0 : Sociology : 5 : 12.5 : 2.5 : 0 :

4865 : Eddie : VanHalen : 0 : Recreation : 6 : 12.7 : 2.11667 : 0 :

3198 : Adam : Ant : 0 : 6 : 6 : 11.5 : 1.91667 : 125 :

Sophomores:

1711 : Rick : Ocasek : 1 : RR : 2 : 8 : 4 : 0 :

7954 : Robert : Palmer : 1 : 56 : 56 : 201 : 3.58929 : 1290 :

9344 : Belinda : Carlisle : 1 : 43 : 43 : 121.5 : 2.82558 : 0 :

4076 : Peter : Buck : 1 : 35 : 35 : 90 : 2.57143 : 0 :

5276 : Eddie : Vetter : 1 : 35 : 35 : 74.3 : 2.12286 : 0 :

3598 : Bill : Berry : 1 : CS : 31 : 60.5 : 1.95161 : 120 :

Juniors:

3874 : Michael : Stipe : 2 : PS : 79 : 311 : 3.93671 : 10 :

2455 : Joe : Strummer : 2 : Business : 68.5 : 254 : 3.70803 : 12.5 :

6502 : Brian : Setzer : 2 : History : 72 : 219.5 : 3.04861 : 0 :

3123 : Bruce : Springsteen : 2 : English : 75 : 225 : 3 : 90 :

0900 : Chrissie : Hynde : 2 : 85 : 85 : 213 : 2.50588 : 0 :

1849 : Michael : Stanley : 2 : Undeclared : 61 : 129 : 2.11475 : 10 :

Seniors:

6378 : Mitch : Easter : 3 : Music : 102 : 376.5 : 3.69118 : 125.43 :

1423 : Joe : Jackson : 3 : Biology : 99 : 345.6 : 3.49091 : 10 :

8576 : Tom : Stoltz : 3 : EE : 103 : 345 : 3.34951 : 0 :

9488 : Mark : Knopfler : 3 : Music : 112 : 345.5 : 3.08482 : 100 :

6138 : Annie : Lennox : 3 : English : 118 : 342 : 2.89831 : 0 :

8602 : Kevin : Rowland : 3 : Physics : 112 : 285.5 : 2.54911 : 1250 :

2779 : Thomas : Dolby : 3 : Science : 112 : 225 : 2.00893 : 1000 :