Answer for C++ coding exercise? - Yahoo! Answers
To get a better understanding of my problem, look at the above post.
Ok so I am having a problem similar to this guy that I saw trying to find someone to give him the answer (2 years ago).
I am not asking for the exact answer, but hints on how to move forward would help.
Code:
Pseudocode for the GetStudentData:
Declare variables
Using a for loop input the data for each student
Dynamically create a Student object and assign it's address to the array
Using a for loop input the data for each course
Dynamically create a Course object
Call the AddCourse method in the Student class passing it
the index position where you want it to go and the address of
the newly created Course object
End-For
Sort the courses for the student
End-For
Pseudocode for the PrintGradeReports:
Using a for loop
Call the Print method for each student
End-For
Pseudocode for the Print method in the Student class
Output the student's information
For each course the student is taking
Call the Print method in the Course class
If the tuition is paid
Output the course grade
Else
Output ***
End-If
End-For
Output the number of credit hours
If the tuition has been paid
Calculate the GPA and output it
Else
Output the message and the amount of tuition the student owes
End-If
I know most of my code is incomplete and I have been looking at an book as an example, but then I realized it's not really a good example...because my teacher is saying to do something different.
I do not really understand the bolded part of the pseudo-code that he has given me. Also, it doesn't help that I'm going to a school where all the information is rushed and I only go two days out of the week. Any kind of help would suffice. I will be on all night today trying to do this and will keep updating until I finish.
Code:
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
class Person
{
private:
string mFirstName;
string mLastName;
public:
string getFirstName()
{
return mFirstName;
}
string getLastName()
{
return mLastName;
}
};
class Course
{
private:
string mCourseName;
string mCourseNumber;
int mCourseCredit;
char mCourseGrade;
public:
void Print()
{
}
string getCourseName()
{
return mCourseName;
}
string getCourseNumber()
{
return mCourseNumber;
}
int getCourseCredit()
{
return mCourseCredit;
}
char getCourseGrade()
{
return mCourseGrade;
}
};
class Student : public Person
{
private:
string mID;
int mNumCourses;
bool mlsTuitionPaid;
Course *mCoursesEnrolled[6];
public:
void SortCourses()
{
}
string getID()
{
return mID;
}
void Print()
{
outfile << "Student Name: " << stPointAr[i]->getFirstName();
}
int GetHoursEnrolled()
{
return mHoursEnrolled;
}
double GetGPA()
{
int i;
double sum = 0;
for (i = 0; i < mNumCourses; i++)
{
switch (Course::getCourseGrade)
{
case 'A':
sum += mCoursesEnrolled[i]->getCourseCredit() * 4;
break;
case 'B':
sum += mCoursesEnrolled[i]->getCourseCredit() * 3;
break;
case 'C':
sum += mCoursesEnrolled[i]->getCourseCredit() * 2;
break;
case 'D':
sum += mCoursesEnrolled[i]->getCourseCredit() * 1;
break;
case 'F':
sum += mCoursesEnrolled[i]->getCourseCredit() * 0;
break;
default:
cout << "Error - Invalid Course Grade." << endl;
}
}
return sum/GetHoursEnrolled();
}
double getBillingAmount()
{
TuitionRate
}
};
const int MAX_STUDENTS = 10;
void GetStudentData();
void PrintGradeReports();
void main()
{
ifstream infile;
ofstream outfile;
int numRegSt;
double TuitionRate;
infile.open("InClass Data.txt");
if(!infile)
{
cout << "Error - input file not found." << endl;
return;
}
outfile.open("OutClass Data.txt");
infile >> numRegSt;
infile >> TuitionRate;
GetStudentData();
PrintGradeReports();
system("Pause");
}
void GetStudentData()
{
ifstream infile;
Student *stPointAr[MAX_STUDENTS];
int numStudents;
for(int i = 0; i < numStudents; i++)
{
infile >> stPointAr[i]->getFirstName()
>> stPointAr[i]->getLastName()
>> stPointAr[i]->getID()
>> stPointAr[i]->mlsTuitionPaid;
if(isPaid == 'Y')
mlsTuitionPaid = true;
else
mlsTuitionPaid = false;
infile >> stPointAr[i]->mNumCourses;
for (int j = 0; j < mNumCourses; j++)
{
infile >>
}
}
}
void PrintGradePoints()
{
for(int i = 0; i < numStudents; i++)
Student::stPointAr[i]->print();
}