CS 010 - Introduction to Computer Science I
Assignment 7:

DUE: Friday, March 5 before 11:00pm


Collaboration Policy

This programming assignment is designed in part for us to determine how well you are able to program. Thus, every part of the program should be your own original work, and should not be substantially similar to other students' code, as well code from books, previous solutions, the web, etc. Like other skills (e.g., surgery), the only way to really learn programming is to do it yourself. Some collaboration is O.K., including discussing the general solution method, and some debugging assistance after a student has tried hard to solve the bug him/herself. We DO encourage you to work with others nearby, so if you get stuck, you can get help. But, you should not show your code to another student in order to help that student. For this assignment, copying code from another source (e.g., copy-and-paste, reading off of another's monitor, etc.) is not considered appropriate collaboration and will have severe consequences.


Turn in online to the appropriate folder for your lab section (e.g., as7_20 for students enrolled in lab section 20). There is a 20% point deduction if your assignment is not in the correct folder.

Remember to add your name, login, SID (last 4 digits), lecture and lab section numbers, and email address, to the header of your program


IMPORTANT:

You must turn in programming assignments as C++ source files. Spaces or non-alphanumeric characters in your filename may cause the turnin to not work. A good name for your file is as7.cpp.


Problem Definition:

You may use the following solution for assignment 6 to help you with this assignment.

as6 solution

Modify your program from the last assignment, as6. For this assignment, allow the user a choice on what the program will do. The choices are:

  1. Print to the file, nice.dat, all student info.
  2. Print to the screen one student's info.
  3. Print to the screen all students graduating in a given month and year.
  4. Exit the program

All student info should be printed to the screen or the file nice.dat with the same heading and format as in assignment 6. You are still required to use a function that gets the data for one student from the input file and another function that outputs the data for one student to the output file. You should add a function that outputs the data for one student to the screen. Each choice, 1 - 3, must be a separate function that is called from one case of a switch statement in main. These functions should call your input and output functions as needed.

The student data in raw.dat is the same as it was for assignment 6:

SID(last 4 digits), GPA(grade point average), DOB(Month, Day, Year: you must use a Date structure to hold this date), Completed Units (number completed so far), Current Units (number taking right now), expected graduation date (use the Date structure to hold this also).

You MUST use the following names for your data files:

     input file: raw.dat
     output file: nice.dat

The following is a sample run of the program using this input file, raw.dat. Your program should produce an output file that looks like this, nice.dat, if the user chooses 1 and they use the given input file. Your program may ask the user how many students are in the input file. You may assume that the file will not hold more than 30 students.

Sample:

     This program uses data from the file raw.dat.

     How many student records are in this input file?
     5

     Choose one of the following options by typing the number and pressing return.

     1. Print all students to the file nice.dat
     2. Print a student of your choice to the screen.
     3. Print all students graduating on a certain date to the screen.
     4. Exit the program.

     1

     The file nice.dat now holds the student records.

     Choose one of the following options by typing the number and pressing return.

     1. Print all students to the file nice.dat
     2. Print a student of your choice to the screen.
     3. Print all students graduating on a certain date to the screen.
     4. Exit the program.

     2

     Enter the last 4 digits of the student's SID: 3456

   SID   GPA      DOB      Total Units  Current Units    Grad Date
  ----  ----  ----------   -----------  -------------   ----------
  3456  2.96  12/ 8/1983       72            13          6/13/2005
     Choose one of the following options by typing the number and pressing return.

     1. Print all students to the file nice.dat
     2. Print a student of your choice to the screen.
     3. Print all students graduating on a certain date to the screen.
     4. Exit the program.

     3

     Enter the month and the year (mm yyyy): 6 2009

   SID   GPA      DOB      Total Units  Current Units    Grad Date
  ----  ----  ----------   -----------  -------------   ----------
  1234  3.50   4/ 9/1985       28            16          6/15/2009
  5678  3.65   8/16/1982       16            16          6/15/2009
     Choose one of the following options by typing the number and pressing return.

     1. Print all students to the file nice.dat
     2. Print a student of your choice to the screen.
     3. Print all students graduating on a certain date to the screen.
     4. Exit the program.

     4


Suggestions:

Code one function at a time and get it working (compile and run your program) before moving on to the next one. In main, design the complete menu, but only test one choice at a time. The untested choices can have stubs or just a message saying something like "choice 3", and then bring up the menu again. Pay close attention to the rubric given below. This is what will be used to grade your assignment.


Compilation policy:

For all remaining programming assignments, if your program does not compile it will not be graded and you will receive 0 points for that assignment.


Rubric: 10 pts total