ECE 2552 SoftwareHardware Integration Grade Point Average Calculator

  • Slides: 25
Download presentation
ECE 2552 Software/Hardware Integration Grade Point Average Calculator (alpha version) 29 th April, 20006

ECE 2552 Software/Hardware Integration Grade Point Average Calculator (alpha version) 29 th April, 20006 Xerxes Beharry

Problem Description n Every Semester my roommate sits around writing in the back of

Problem Description n Every Semester my roommate sits around writing in the back of his notebooks trying to figure out what his semester GPA by hand. n He often made mistakes and then came to me so that I could calculate it.

Solution n Design a GPA calculator that is able to take a brief course

Solution n Design a GPA calculator that is able to take a brief course description, number of credit hours and the grade for each semester. n 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? n 3 header files n n Course. h Semester. h

How was it done? n 3 header files n n Course. h Semester. h All. Records. h 4 Source files n n Course. cpp Semester. cpp All. Records. cpp Main I used Classes to represent Course information Semester And a collection of Semesters

How was it done (cont) n Each student takes courses which has a course

How was it done (cont) n Each student takes courses which has a course name, credit hours and the associated grade given at the end of the semester. n A collection of these courses make up a semester n A collection of semesters make up a students record

How was it done (cont) n Course contains name, hours and grade n Semesters

How was it done (cont) n Course contains name, hours and grade n Semesters is an array of courses n Record is an array of semesters

Course. h & Course. cpp n Sets Course Name, Credit Hours and Grade n

Course. h & Course. cpp n Sets Course Name, Credit Hours and Grade n Gets Course Name, Credit Hours and Grade n Displays the Course Name, Credit Hours and Grade n Gets the quality points from the entered grade

Semester. h & Semester. cpp n Semester class has an array of a max

Semester. h & Semester. cpp n Semester class has an array of a max of 15 courses n Adds Course (course name, hours and grade) to the course array n Gets the all the credit hours for a semester to calculate the Cumulative GPA n Calculates the Semester GPA n Displays each Course for the Semester

Semester. h & Semester. cpp (cont) bool Semesters: : add. Course(string course. Name, int

Semester. h & Semester. cpp (cont) bool Semesters: : add. Course(string course. Name, int credits, char grade) //adds course information { //example of built in error checking from an online example course[curr. Course]. setcoursename(course. Name); course[curr. Course]. setcredithours(credits); course[curr. Course]. setgrade(grade); //sets the course name in the array //sets the credit hours in the array //sets the grade in the array curr. Course++; //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: : get. Grade. Point. Total() //returns

Semester. h & Semester. cpp (cont) double Semesters: : get. Grade. Point. Total() //returns sigma quality points * credithours for the semester { double sum. Grades = 0; for(int i = 0; i < curr. Course; ++i) //loops for as many courses entered sum. Grades += course[i]. getqualpts() * course[i]. getcredithours(); return sum. Grades; hours // returns sigma quality points*credit } // curr. Course tells how many courses were entered for the semester

Semester. h & Semester. cpp (cont) void Semesters: : display. Transcript() { for(int i

Semester. h & Semester. cpp (cont) void Semesters: : display. Transcript() { for(int i = 0; i < curr. Course; ++i) course[i]. display. Course(); } //loops for as many courses entered //displays each record for course name, credit hours and grade //end display //Displays each course for the semester

All. Records. h & All. Records. cpp n Allrecords class has an array of

All. Records. h & All. Records. cpp n Allrecords class has an array of max 10 semesters n Calculates the Cumulative GPA n Display either all or a single semester grades

All. Records. h & All. Records. cpp(cont) void All. Records: : add. Semester(int index

All. Records. h & All. Records. cpp(cont) void All. Records: : add. Semester(int index , Semesters& sem) //checks which semester is being added and then places the { //sem object in the semester shelf index--; //user enters 1 st semester-> array position 0 semester[index] = sem; //sets the sem pointer to the correct array position curr. Semester++; } The address of which semester is set to sem //incremenets the counter

Main. cpp Switch Case for Menu Options n Attempted to Use files to save

Main. cpp Switch Case for Menu Options n Attempted to Use files to save and load profiles n Create Profile n Load Profile n Select Semester n Add Grades n Display Transcript n

Main. cpp (contd) case 3: { //user changes semester cout << "Enter Semester (1

Main. cpp (contd) case 3: { //user changes semester cout << "Enter Semester (1 - 10): "; cin >> current. Semester ; while(current. Semester < 1 || current. Semester >=10) //loops to get the current semester { cout << "Enter Semester (1 - 10): "; cin >> current. Semester ; //needs to be corrected for array position } sem = &student. Records. get. Semester(current. Semester); //addresss of the current semester //sem is a pointer to an object } break;

Main. cpp (contd) case 4: { …… (*sem). add. Course(name, credits, grade); //pointer to

Main. cpp (contd) case 4: { …… (*sem). add. Course(name, credits, grade); //pointer to which semester and adds course information student. Records. add. Semester(current. Semester, *sem); //points to which semester to add the course information } Adds courses to semester Adds semester to the Records

Sample Output

Sample Output

What got me frustrated n Converting the grade to quality points int GPA: :

What got me frustrated n 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) n Files n Trying to read the data from

What got me frustrated (cont) n Files n Trying to read the data from the file. The last entry would repeat its self

Most Proud Of n How to convert grade to quality points? int Course: :

Most Proud Of n How to convert grade to quality points? int Course: : getqualpts() { int points[4] = {4 , 3 , 2 , 1}; int pts = 0; //function to convert grade to qualtiy points //array with the amt of points //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 All. Records: : calculate. Total. GPA() Cumalative GPA {

Most Proud Of (cont) double All. Records: : calculate. Total. GPA() Cumalative GPA { double sum. Grades = 0; hours double sum. Hrs = 0; for(int i = 0; i < 10; ++i) } //calculate //cumalative sigma quality pts * credit //cumalative sigma hours //for coutner < than maximum number of semesters //for coutner < number of courses taken per semester for(int j = 0; j < semester[i]. get. Courses(); ++j) { sum. Grades += semester[i]. get. Grade. Point. Total(); //cumalative sigma gradepts*hrs sum. Hrs += semester[i]. get. All. Credits(); //cumalative sigma hours } return sum. Grades / sum. Hrs; //returns cumalative GPA //end cum gpa For each of the 10 semesters, for the number of courses taken each semester

Improvements n Should check if semester is valid before entering course information n Should

Improvements n Should check if semester is valid before entering course information n Should check for valid amount of credit hours n Should be able to save and load student profiles, to prevent user from having to re-enter entire records every time program is run n More User friendly Interface

What I learnt from this project n You are never finished programming n Code

What I learnt from this project n You are never finished programming n Code simple cases and then expand to bigger cases n 2 heads are better than 1 n Remember the #include & using std: :

Acknowledgment David Fowler n Sean Powers n Daewon Song n

Acknowledgment David Fowler n Sean Powers n Daewon Song n

Questions?

Questions?