DUE: Tuesday, May 25 before 11:00pm
Collaboration is strictly FORBIDDEN. Programs must represent YOUR OWN original work. Sharing code or team-coding are not allowed for this assignment. Copying code from ANY source (any book, current or past students, past solutions, the web, etc.) is not allowed. Cooperation to the extent of helping to debug, or discussing the general approach to solving the problem is encouraged, but should never involve communicating code or even pseudo-code or explicit algorithms. Your code must be unique -- if it is not, we will find out, and will treat it as a case of flagrant academic dishonesty.
You must turn in a C++ source file (and only a C++ source file). The name for your source file should be as7.cpp.
Turn in online to the appropriate folder for your lab section (e.g., as7_sec20 for students enrolled in lab section 20). If you turn your assignment in to the wrong folder, your assignment may not be graded. If it is graded, you will lose 2 pts (out of 10).
Remember to include the header as it is in the template provided on the class website.
Write a program that reads in data from an input file, students.txt, and outputs a letter to the student with the highest gpa. The letter should just be an output file called letter.txt. It must have the same formatting and order as the example letter.txt given below.
The input file will have, in this order, each student's id, last name, first name, address (street city state zip code), phone number (area prefix extension), email address, and gpa. You must read these into a structure. The structure will contain all the info for one student. You can assume the input file will be set up exactly the way the sample input file given below is set up. In other words, the id will be on the first line, the last name followed by the first name will be on the second line, the street address will be on the third line, the city, state, and zip code will be on the fourth line, etc.
You must use at least 2 functions. One function for reading in input from the input file and one function for writing the letter (the output file). The input file must return one student object.
You may use this input file, students.txt, to help you test your program. For reference, here is the output file letter.txt that should be generated given this sample input file. We will use a different input file to test your program, but the format and order of your letter should be the same.
For 1 pt BONUS use a structure to store the address and another structure to store the phone number. Then use these new object types as member variables of your student structure.
If your program does not compile, it will not be graded. Compile your code often. Only write a small portion of code before checking that it still compiles. This way when you get a syntax error, you can be fairly certain the error is in the part you just wrote.
2 pts: File I/O
- (1 pt) File objects connected (opened) correctly.
- (.5 pt) Program exits (with error message) if a file open failed.
- (.5 pt) File objects disconnected (closed).
4 pts: Functions
- (2 pts) DOES NOT USE GLOBAL VARIABLES/OBJECTS.
- (1 pt) Input function (returns one object holding all of one
student's info).
- (1 pt) Output function
2 pts: Correct output
- (1 pt) Outputs letter in correct format and order.
- (1 pt) Outputs correct info of student with highest gpa.
2 pts: Style
- (.5 pts) Good variable/function names
- (.5 pts) Proper indentation/spacing
- (.5 pts) Good comments (including header and function comments)
- (.5 pts) No line wraps