250 likes | 263 Views
ECE 2552 Software/Hardware Integration. Grade Point Average Calculator (alpha version) 29 th April, 20006 Xerxes Beharry. Problem Description. Every Semester my roommate sits around writing in the back of his notebooks trying to figure out what his semester GPA by hand.
E N D
ECE 2552Software/Hardware Integration Grade Point Average Calculator (alpha version) 29th April, 20006 Xerxes Beharry
Problem Description • Every Semester my roommate sits around writing in the back of his notebooks trying to figure out what his semester GPA by hand. • He often made mistakes and then came to me so that I could calculate it.
Solution • Design a GPA calculator that is able to take a brief course description, number of credit hours and the grade for each semester. • Ideally it would be able to store the grades for each semester to a file which can be loaded and viewed at any time
How was it done? • 3 header files • Course.h • Semester.h • AllRecords.h • 4 Source files • Course.cpp • Semester.cpp • AllRecords.cpp • Main I used Classes to represent Course information Semester And a collection of Semesters
How was it done (cont) • Each student takes courses which has a course name, credit hours and the associated grade given at the end of the semester. • A collection of these courses make up a semester • A collection of semesters make up a students record
How was it done (cont) • Course contains name, hours and grade • Semesters is an array of courses • Record is an array of semesters
Course.h & Course.cpp • Sets Course Name, Credit Hours and Grade • Gets Course Name, Credit Hours and Grade • Displays the Course Name, Credit Hours and Grade • Gets the quality points from the entered grade
Semester.h & Semester.cpp • Semester class has an array of a max of 15 courses • Adds Course (course name, hours and grade) to the course array • Gets the all the credit hours for a semester to calculate the Cumulative GPA • Calculates the Semester GPA • Displays each Course for the Semester
Semester.h & Semester.cpp (cont) bool Semesters::addCourse(string courseName, int credits, char grade) //adds course information { //example of built in error checking from an online example course[currCourse].setcoursename(courseName); //sets the course name in the array course[currCourse].setcredithours(credits); //sets the credit hours in the array course[currCourse].setgrade(grade); //sets the grade in the array currCourse++; //index that keeps track of the how many courses are entered for a semester return true; //returns a true value if the course was added successfully } After a course is entered the counter is used to go to the next position of the array
Semester.h & Semester.cpp (cont) double Semesters::getGradePointTotal() //returns sigma quality points * credithours for the semester { double sumGrades = 0; for(int i = 0; i < currCourse; ++i) //loops for as many courses entered sumGrades += course[i].getqualpts() * course[i].getcredithours(); return sumGrades; // returns sigma quality points*credit hours } // currCourse tells how many courses were entered for the semester
Semester.h & Semester.cpp (cont) void Semesters::displayTranscript() { for(int i = 0; i < currCourse; ++i) //loops for as many courses entered course[i].displayCourse(); //displays each record for course name, credit hours and grade } //end display //Displays each course for the semester
AllRecords.h & AllRecords.cpp • Allrecords class has an array of max 10 semesters • Calculates the Cumulative GPA • Display either all or a single semester grades
AllRecords.h & AllRecords.cpp(cont) void AllRecords::addSemester(int index , Semesters& sem) //checks which semester is being added and then places the { //sem object in the semester shelf index--; //user enters 1st semester-> array position 0 semester[index] = sem; //sets the sem pointer to the correct array position currSemester++; //incremenets the counter } The address of which semester is set to sem
Main.cpp • Switch Case for Menu Options • Attempted to Use files to save and load profiles • Create Profile • Load Profile • Select Semester • Add Grades • Display Transcript
Main.cpp (contd) case 3: { //user changes semester cout << "Enter Semester (1 - 10): "; cin >> currentSemester ; while(currentSemester < 1 || currentSemester >=10) //loops to get the current semester { cout << "Enter Semester (1 - 10): "; cin >> currentSemester ; //needs to be corrected for array position } sem = &studentRecords.getSemester(currentSemester); //addresss of the current semester //sem is a pointer to an object } break;
Main.cpp (contd) case 4: { …… (*sem).addCourse(name,credits,grade); //pointer to which semester and adds course information studentRecords.addSemester(currentSemester,*sem);//points to which semester to add the course information } Adds courses to semester Adds semester to the Records
What got me frustrated • Converting the grade to quality points int GPA::getqualpts() //function to convert grade to qualtiy points { int points; //value of quality points //checks letter grade and returns the equivalent number of quality points if(grade==‘A’ ||grade==‘a ‘) { points=4; } if(grade==‘B’ ||grade==‘b’) { points=3; } if(grade==‘C’||grade==‘c’) { points=2; return points;
What got me frustrated (cont) • Files • Trying to read the data from the file. The last entry would repeat its self
Most Proud Of • How to convert grade to quality points? int Course::getqualpts() //function to convert grade to qualtiy points { int points[4] = {4 , 3 , 2 , 1}; //array with the amt of points int pts = 0; //returns 4=A,3=B,2=C,1=D,0=F if(grade >= 'A' && grade <= 'D') //checks for a valid grade pts = points[grade - 'A']; //difference of ascii - ascii letter grade = pts return pts; //returns the qualtiy points } void Course::setgrade(char grade_char) { grade = toupper(grade_char); //takes care of upper and lower case characaters } //end set grade function
Most Proud Of (cont) double AllRecords::calculateTotalGPA() //calculate Cumalative GPA { double sumGrades = 0; //cumalative sigma quality pts * credit hours double sumHrs = 0; //cumalative sigma hours for(int i = 0; i < 10; ++i) //for coutner < than maximum number of semesters //for coutner < number of courses taken per semester for(int j = 0; j < semester[i].getCourses(); ++j) { sumGrades += semester[i].getGradePointTotal(); //cumalative sigma gradepts*hrs sumHrs += semester[i].getAllCredits(); //cumalative sigma hours } return sumGrades / sumHrs; //returns cumalative GPA } //end cum gpa For each of the 10 semesters, for the number of courses taken each semester
Improvements • Should check if semester is valid before entering course information • Should check for valid amount of credit hours • Should be able to save and load student profiles, to prevent user from having to re-enter entire records every time program is run • More User friendly Interface
What I learnt from this project • You are never finished programming • Code simple cases and then expand to bigger cases • 2 heads are better than 1 • Remember the #include & using std::
Acknowledgment • David Fowler • Sean Powers • Daewon Song