Sonoma State University Computer Science Department CS 115 Fall 2010 Watts Project 3 Part 1 For this part of the project you will be modifying one of the programs you submitted for Lab 8 to calculate your CS 115 percentage and letter grade. Specifications: 1. Create a copy of your Lab8e.cpp program for Project 3 cd cs115 mkdir Proj3 cd Proj3 cp../lab8/lab8e.cpp Proj3.cpp 2. Currently the program calculates a single percentage using the formula Percentage = 100 * (the sum of the actual scores) / (the sum of the possible scores) In CS 115, a separate percentage is calculated for your labs and homeworks (LH%), your projects (P%), and your quizzes and exams (QE%). The overall percentage is calculated using the formula Percentage = 0.2 * LH% + 0.3 * P% + 0.5 * QE% 3. Modify the function ComputePctScore as follows: a. Add a new character variable to contain the assignment type called atype; b. Modify the input statement to read in atype before it reads in earned and possible. c. Change the name of the variable total_earned to LH_earned and the name of the variable total_possible to LH_possible. Add similar variables for the projects (P) and the Quizzes and exams (QE). d. If atype is L or H, add the value of earned to LH_earned and the value of possible to LH_possible. Similarly, if atype is P add earned and possible to the appropriate variables and if type is Q or E add earned and possible to the appropriate variables. e. After you have read all of the assignment information from the file, calculate the individual percentage values for LH, P, and QE. f. Calculate and return the overall percentage. 4. The input file will contain a line for each assignment. Each assignment line will have the format: character_assignment_type integer_earned integer_possible 5. Modify the main function so tht it prints the overall average and a corresponding letter grade as indicated in the table below: Score Range Letter grade 90 100% A 80 89% B 70 79% C 60-69% D 0 59% F 6. Test input files called p3scores1.in and p3scores2.in can be copied from the cs115pickup folder: cp ~tiawatts/cs115pickup/p3scores*.in.
Date Due: Sunday, 31 October 2010, 11:59 pm. To Turn In: A well documented and formatted C++ program and a text description file. The C++ program should be called lastfp3.cpp and the text description file should be called lastfp3.txt. The text file should describe the issues you encountered while writing the program. Sample Input File 10 L 9 10 L 8 10 H 10 10 L 10 10 P 55 50 Q 7 10 E 85 100 P 48 50 L 10 10 H 8 10 Corresponding Output Please enter the name of the file: p3scores1.in Your percent is 91.0515% Your grade is A. Sample Input File 10 L 7 10 L 8 10 H 6 10 L 10 10 P 45 50 Q 7 10 E 75 100 P 38 50 L 10 10 H 8 10 Corresponding Output Please enter the name of the file: p3scores2.in Your percent is 78.5061% Your grade is C.
Sonoma State University Computer Science Department CS 115 Fall 2010 Watts Project 3 Part 2 For this part of the project you will be modifying the program you submitted for Project 3 Part1. Specifications: 1. Create a copy of the file you turned for project 3. 2. Modify the program to store the assignment information in arrays. You will need 5 arrays: char atype [MAX]; int earned [MAX]; int possible [MAX]; string date [MAX]; string name [MAX]; where MAX is defined at the beginning of your program as a constant integer: const int MAX = 100; 3. Modify the program to read the date and name of the assignment. a. The date of the assignment will be in the format yyyy/mm/dd and will follow the possible points for the assignment. There will be one space between the possible points and the date. b. The name of the will follow the date for the assignment. There will be 1 space between the date and the name of the assignment. There will be nothing on the input line after the name of the assignment. The name of the assignment may contain more than 1 word. 4. Modify the program to read from the input file until it reaches the end of the file. 5. Modify the program to count the number of assignments in the file. Modify the program to print the number of assignments. 6. Modify the program to print information about the assignments after it prints the number of assignments. 7. Modify the program to print the percentage grades for each of the 3 categories (Labs and Homeworks, Projects, Quizzes and Exams). 8. A test input file called p3scores3.in can be copied from the cs115pickup folder: cp ~tiawatts/cs115pickup/p3scores3.in. 9. Here are some sample prototypes and a version of main which uses these prototypes. using namespace std;
const int MAX = 100; // Function to open file and read data into arrays. // Will return numbor of assignments (-1 if the file cannot be read) int InputScores(ifstream& input, char T[], int E[], int P[], string D[], string N[]); // Function to print data from the arrays. void PrintScores (int numscores, char T[], int E[], int P[], string D[], string N[]); // Function to calculate and return the overall percentage score using the // data in the arrays. Will also print the percentage score for each category. float ComputePctScore(int numscores, char T[], int E[], int P[], string D[], string N[]); // Function to determine the letter grade for the overall percent score. char DetermineGrade (float pct); int main() { ifstream inputfile; int numscores; char atype [MAX]; int earned [MAX]; int possible [MAX]; string date [MAX]; string name [MAX]; // Variable for input file // Number of scores stored in the input file // Array to hold assignment types // Array to hold assignment earned scores // Array to hold assignment possible scores // Array to hold assignment dates // Array to hold assignment names // Call a function to open the input file and the data into the arrays. numscores = InputScores(inputFile, atype, earned, possible, date, name); // If there was an error reading the file, output a message and exit. if (numscores == -1) { cout << "Could not read input file\n"; exit (1); } cout << "There are " << numscores << " assignments in the file\n"; // Call function to print assignment data from the arrays. PrintScores(numScores, atype, earned, possible, date, name); // Call a function to compute the overall percentage score. // This function will also print out the percent score for each category. float percent = ComputePctScore(numScores, atype, earned, possible, date, name); cout << "Your percent is " << percent << "%\n"; // Call function to determine letter grade for percent score. cout << "Your grade is " << DetermineGrade (percent) << endl; // Close the input file inputfile.close(); } return 0;
Date Due: Wednesday, 10 November 2010, 11:59 pm (Please DO NOT submit before 1 November 2010). To Turn In: A well documented and formatted C++ program and a text description file. The C++ program should be called lastfp3-2.cpp and the text description file should be called lastfp3.txt. The text file should describe the issues you encountered while writing the program.; this file should include issues from Project 3 Parts 1 & 2. Sample Input File L 5 5 2010/08/25 Lab 2 Program E 94 100 2010/10/13 Exam 1 Corresponding Output Please enter the name of the file: p3scores3.in There are 12 assignments in the file L 5 5 2010/08/25 Lab 2 Program E 94 100 2010/10/13 Exam 1 Your Lab and Homework percent is 80% Your Project percent is 103% Your Quiz and Exam percent is 94.5455% Your percent is 94.1727% Your grade is A.
Sonoma State University Computer Science Department CS 115 Fall 2010 Watts Project 3 Part 3 For this part of the project you will be modifying the program you submitted for Project 3 Part 2. This is the final part of this project. Specifications: 1. Create a copy of the file you turned for project 3 part 2. 2. Modify your program to expect a type of T for an exam instead of a type of E. 3. Add several new prototypes to your program: // Function to swap two integer values void Swap (int & a, int & b); // Function to swap two string values void Swap (string & a, string & b); // Function to swap two character values void Swap (char & a, char & b); // Fuction to sort the parallel data arrays void Sort (int numscores, char T[], int E[], int P[], string D[], string N[]); // Fuction to print a formatted report of the assignments and percentage grades void PrintReport (int numscores, char T[], int E[], int P[], string D[], string N[]); 4. Create stubbs at the end of the file for each of your new functions. 5. Implement the Swap and Sort functions as described in class. 6. Add a call to the Sort function and another call to the PrintScores function in your main function after the existing call to the PrintScores function: // Call function to print assignment data from the arrays. PrintScores(numScores, atype, earned, possible, date, name); cout << endl; // Call function to sort the assignment data in the arrays. Sort(numScores, atype, earned, possible, date, name); // Call function to print assignment data from the sorted arrays. PrintScores(numScores, atype, earned, possible, date, name); cout << endl; 7. Copy the file p3scores3.txt from ~tiawatts/cs115pickup. Compile and execute your program. Make sure that the assignments are sorted, first by type and then by date within type: Please enter the name of the file: p3scores3.txt There are 12 assignments in the file
L 5 5 2010/08/25 Lab 2 Program T 94 100 2010/10/13 Exam 1 L 5 5 2010/08/25 Lab 2 Program T 94 100 2010/10/13 Exam 1 Your Lab and Homework percent is 80% Your Project percent is 103% Your Quiz and Exam percent is 94.5455% Your percent is 94.1727% Your grade is A 8. Modify the function PrintReport to print a report in the following format for the sorted assignments: Type Earned Possible Date Assignment Name L 5 5 2010/08/25 Lab 2 Program 32 40 Your Lab and Homework percent is 80% Type Earned Possible Date Assignment Name 103 100 Your Project percent is 103% Type Earned Possible Date Assignment Name T 94 100 2010/10/13 Exam 1 104 110 Your Quiz and Exam percent is 94.5455% Your overall percent is 94.1727% Your grade is A
12. Modify the main function of your program to call the Sort and the PrintReport functions instead of PrintScores, ComputePctGrade, and DetermineGrade. Your final main function should look like: int main() { ifstream inputfile; int numscores; char atype [MAX]; int earned [MAX]; int possible [MAX]; string date [MAX]; string name [MAX]; // Variable for input file // Number of scores stored in the input file // Array to hold assignment types // Array to hold assignment earned scores // Array to hold assignment possible scores // Array to hold assignment dates // Array to hold assignment names // Call a function to open the input file and the data into the arrays. numscores = InputScores(inputFile, atype, earned, possible, date, name); // If there was an error reading the file, output a message and exit. if (numscores == -1) { cout << "Could not read input file\n"; exit (1); } // Call function to sort assignment data in the arrays. Sort(numScores, atype, earned, possible, date, name); // Call function to print formatted report of the data in the arrays. PrintReport(numScores, atype, earned, possible, date, name); // Close the input file inputfile.close(); } return 0; Date Due: Wednesday, 1 December 2010, 11:59 pm (Please DO NOT submit before 20 November 2010). To Turn In: A well documented and formatted C++ program and a text description file. The C++ program should be called lastfp3-3.cpp and the text description file should be called lastfp3.txt. The text file should describe the issues you encountered while writing the program; this file should include issues from Project 3 Parts 1, 2 & 3.