well... its me again with another project following the basics of the last one...
heres my header file:
#ifndef SCHEDULE_H
#define SCHEDULE_H
#include<string>
class schedule
{
public:
// this section will display the heading for the output table
void printHead ();
//This function is used to calculate the totalgpa for one class
int calcGradePoint(aGrade, int, int&);
//This bubblesort is used to put the courses into alphabetical order
void sortClass(string, int, char, int);
//This function is used to calculate overall gpa = totalofgpa / totalhours
float calcGPA(float, int);
//this function will print the output lines in the table
void printLine ();
private:
int hours[50], cnt = 0; //Variables used
char grades[50], gpaForOneClass[50];
string courses[50];
float gpa = 0.0, totalHours = 0, gpaSum = 0;
gradevalue in;
enum aGrade {a, b, c, d, f, w, i};
};
#endif // SCHEDULE_H
and here is my schedule.cpp:
#include "schedule.h"
#include<iostream> // all the classes I could ever need for this program
#include<iomanip> // and a few extra just incase.
#include<cmath>
#include<cstdlib>
#include<string>
using namespace std;
enum aGrade {a, b, c, d, f, w, i};
int hours[50], cnt = 0; //Variables used
char grades[50], gpaForOneClass[50];
string courses[50];
float gpa = 0.0, totalHours = 0, gpaSum = 0;
aGrade in;
void schedule::printHead () // this section will display the heading for the output table
{
cout<<"\n\nList of the Courses"<<endl<<"\n Class Hours Grade \n";
cout<<"-----------------------------------"<<endl;
}
aGrade convert(aGrade in, //OUT: in
char grades) //IN: grades
{
switch (grades) //switch stmt to get all the letters into the enum catagories
{
case 'a':case 'A':
in = a;
break;
case 'b':case 'B':
in = b;
break;
case 'c':case 'C':
in = c;
break;
case 'd':case 'D':
in = d;
break;
case 'f':case 'F':
in = f;
break;
case 'w':case 'W':
in = w;
break;
case 'i':case 'I':
in = i;
break;
}
return in;
}
int schedule::calcGradePoint(aGrade in, //IN: in
int hours, // IN: hours
int& cnt) //INOUT: cnt
//This function is used to calculate the totalgpa for one class
{
if(in == a)
return 4 * hours;
if(in == b)
return 3 * hours;
if(in == c)
return 2 * hours;
if(in == d)
return 1 * hours;
if(in == f)
return 0 * hours;
if(in == w)
return 0 * hours;
if(in == i)
return 0 * hours;
else
cout<<"\nInvalid entry"<<endl;
cnt = cnt - 1;
}
void schedule::sortClass(string courses[], //INOUT: courses
int hours[], //INOUT: hours
char grades[], //INOUT: grades
const int cnt) //IN: cnt
//This bubblesort is used to put the courses into alphabetical order
{
int i = cnt, j = 0, k = 1, temper;
string temp;
char tmp;
while (i >= 0 && k)
{
k = 0;
for (j = 0; j <= i; j++)
if (courses[j] > courses[j+1])
{
temp = courses[j];
courses[j] = courses[j+1];
courses[j+1] = temp;
temper = hours[j];
hours[j] = hours[j+1];
hours[j+1] = temper;
tmp = grades[j];
grades[j] = grades[j+1];
grades[j+1] = tmp;
k = 1;
}
i--;
}
}
float schedule::calcGPA(const float gpaSum, //IN: gpaSum
const int totalHours ) //IN: totalHours
//This function is used to calculate overall gpa = totalofgpa / totalhours
{
float gpa;
gpa = float (gpaSum / totalHours);
return gpa;
}
void schedule::printLine (const int cnt, int b, string courses[], int hours[], char grades[], float gpa, int totalHours)
{
for (int b = 1; b <= cnt; b++) //puts the information into the table
{
cout<<setw(12)<<courses[b]<<setw(9)<<hours[b]<<setw(10)<<grades[b]<<endl;
}
cout<<"\nThe total GPA is "<<gpa<<" and you attempted "<<totalHours<<" hours."<<endl;
}
here are my compiling errors.
64 schedule.cpp prototype for ` int schedule::calcGradePoint(aGrade, int, int&)' does not match any in class
15 schedule.h int schedule::calcGradePoint()
91 schedule.cpp prototype for ` void schedule::sortClass(std::string*, int*, char*, int)' does not match any
19 schedule.h void schedule::sortClass()
127 schedule.cpp prototype for ` float schedule::calcGPA(float, int)' does not match any in class `schedule'
23 schedule.h float schedule::calcGPA()
135 schedule.cpp prototype for ` void schedule::printLine(int, int, std::string*, int*, char*, float, int)'
27 schedule.h void schedule::printLine()
heres my grading points for this lab:
Grading Points:
1) Use the following type definitions:
enum aGrade {A, B, C, D, F, W, I};
struct aClass
{
string course;
aGrade grade;
int hours;
int GP;
};
2) All variables must be local.
3) All functions and type definitions must be in a header file (*.h).
4) All function bodies must be in a separate body file (*.cpp) from the main.
5) An array of 10 structures of type aClass will make up the storage mechanism; i.e., you will process 10 students.
6) Comment all functions thoroughly: InOut, Out, requires, ensures.
7) Input must be inline (i.e. all values entered on the same line)
$>class grade hours
8 ) Allow both upper and lower case entries for grades.
9) Accept “quit, “Quit, and “QUIT as acceptable terminators for loop
10) Use the following functions:
printHead //Prints the top of the display chart
printLine //Prints 1 line of the table
calcGradePoints //Calculates grade points for structure
calcGPA //Calculates total GPA
sortClass //Uses a bubble sort to put classes in order
I and reading in my text book and trying to figure this out... i dont care about the struct yet. And i didn't include my main function. I just want to see where i am going wrong with this header file/class