#ifndef StudentsH
#define StudentsH
#include <string>
using namespace std;
namespace Students
{
enum StudentGender { sgUnspecified, sgMale, sgFemale };
namespace Registration
{
class Student
{
public:
Student();
Student(string fn, string ln);
Student(string F, string L, int g);
~Student();
void setFirstName(const string FN) { FirstName = FN; }
string getFirstName() { return FirstName; }
void setLastName(const string LN) { LastName = LN; }
string getLastName() { return LastName; }
void setFullName(const string FN, const string LN);
string getFullName();
void setGender(const int g) { Gender = g; }
string getGender() const;
private:
string FirstName;
string LastName;
int Gender;
};
} // namespace Registration
} // namespace Students
#endif // StudentsH
|
#include "Students.h"
namespace Students
{
namespace Registration
{
Student::Student()
: FirstName("John"),
LastName("Doe"),
Gender(0)
{
}
Student::Student(string fn, string ln)
: FirstName(fn),
LastName(ln),
Gender(0)
{
}
Student::Student(string F, string L, int g)
: FirstName(F),
LastName(L),
Gender(g)
{
}
Student::~Student()
{
}
void Student::setFullName(const string FN, const string LN)
{
setFirstName(FN);
setLastName(LN);
}
string Student::getFullName()
{
return getFirstName() + " " + getLastName();
}
string Student::getGender() const
{
if( Gender == sgMale )
return "Male";
else if( Gender == sgFemale )
return "Female";
else
return "Unspecified";
}
} // namespace Registration
} // namespace Students
|
#ifndef GradesH
#define GradesH
namespace Students
{
class Grades
{
public:
Grades();
Grades(double e, double s, double h,
double g, double c, double o,
double m, double p, double r, double t);
~Grades();
void setEnglish(const double e) { English = e; }
double getEnglish() const { return English; }
void setSecondLng(const double s) { SecondLng = s; }
double getSecondLng() const { return SecondLng; }
void setHistory(const double h) { History = h; }
double getHistory() const { return History; }
void setGeography(const double g) { Geography = g; }
double getGeography() const { return Geography; }
void setChemistry(const double c) { Chemistry = c; }
double getChemistry() const { return Chemistry; }
void setSociology(const double o) { Sociology = o; }
double getSociology() const { return Sociology; }
void setMath(const double m) { Math = m; }
double getMath() const { return Math; }
void setCompSc(const double p) { CompSc = p; }
double getCompSc() const { return CompSc; }
void setMorale(const double a) { Morale = a; }
double getMorale() const { return Morale; }
void setSports(const double t) { Sports = t; }
double getSports() const { return Sports; }
private:
double English;
double SecondLng;
double History;
double Geography;
double Chemistry;
double Sociology;
double Math;
double CompSc;
double Morale;
double Sports;
};
} // namespace Students
#endif
|
#include "Grades.h"
namespace Students
{
Grades::Grades()
{
English = 0.00;
SecondLng = 0.00;
History = 0.00;
Geography = 0.00;
Chemistry = 0.00;
Sociology = 0.00;
Math = 0.00;
CompSc = 0.00;
Morale = 0.00;
Sports = 0.00;
}
Grades::Grades(double e, double s, double h,
double g, double c, double o,
double m, double p, double r, double t)
{
English = e;
SecondLng = s;
History = h;
Geography = g;
Chemistry = c;
Sociology = o;
Math = m;
CompSc = p;
Morale = r;
Sports = t;
}
Grades::~Grades()
{
}
} // namespace Students
|
#ifndef StudentsIssuesH
#define StudentsIssuesH
#include "Students.h"
#include "Grades.h"
using namespace Students::Registration;
namespace Students
{
class StudentsIssues
{
public:
StudentsIssues();
~StudentsIssues();
void RegisterStudent();
void ProcessGrades();
void ProcessStudent();
void ShowStudentIdentification();
void ShowStudentGrades();
void DisplayReport();
private:
double CalculateTotal() const;
double CalculateMean() const;
Student Pupil;
Grades Marks;
double TotalGrades;
double AverageGrades;
};
} // namespace Students
#endif // StudentsIssuesH
|
#include <iostream>
#include <iomanip>
#include "StudentsIssues.h"
using namespace std;
namespace Students
{
StudentsIssues::StudentsIssues()
{
}
StudentsIssues::~StudentsIssues()
{
}
// This method is use to register one student
void StudentsIssues::RegisterStudent()
{
string FN, LN;
int Gdr;
cout << " - = - Red Oak High School - = -";
cout << "\nPlease register the student\n";
cout << "\nEnter the student's information\n";
cout << "First Name: "; cin >> FN;
cout << "Last Name: "; cin >> LN;
cout << "Gender: ";
cout << "\n1 - Male"
<< "\n2 - Female"
<< "\n3 - Unspecified"
<< "\nYour Choice: ";
cin >> Gdr;
Pupil.setFullName(FN, LN);
Pupil.setGender(Gdr);
}
// This method is used to enter grades for a student
void StudentsIssues::ProcessGrades()
{
double Language1, Language2, Hist, Geog,
Chem, Soc, Math, CompSc, Mor, Sport;
cout << "\nEnter student's grades\n";
cout << "English: "; cin >> Language1;
cout << "2nd Language: "; cin >> Language2;
cout << "History: "; cin >> Hist;
cout << "Geography: "; cin >> Geog;
cout << "Chemistry: "; cin >> Chem;
cout << "Sociology: "; cin >> Soc;
cout << "Mathematics: "; cin >> Math;
cout << "Comp Sciences: "; cin >> CompSc;
cout << "Morale: "; cin >> Mor;
cout << "Sports: "; cin >> Sport;
Marks.setEnglish(Language1);
Marks.setSecondLng(Language2);
Marks.setHistory(Hist);
Marks.setGeography(Geog);
Marks.setChemistry(Chem);
Marks.setSociology(Soc);
Marks.setMath(Math);
Marks.setCompSc(CompSc);
Marks.setMorale(Mor);
Marks.setSports(Sport);
}
double StudentsIssues::CalculateTotal() const
{
double Total = Marks.getEnglish() + Marks.getSecondLng() +
Marks.getHistory() + Marks.getGeography() +
Marks.getChemistry() + Marks.getSociology() +
Marks.getMath() + Marks.getCompSc() +
Marks.getMorale() + Marks.getSports();
return Total;
}
double StudentsIssues::CalculateMean() const
{
return TotalGrades / 10;
}
// This method is used to display information about a student
void StudentsIssues::ShowStudentIdentification()
{
cout << "\n=======================================";
cout << "\n - = - Red Oak High School - = -";
cout << "\n=======================================";
cout << "\nStudent Identification";
cout << "\nFull Name: "
<< Pupil.getFirstName() << " "
<< Pupil.getLastName();
cout << "\nGender: " << Pupil.getGender() << endl;
}
// This method is used to display grades for a student
void StudentsIssues::ShowStudentGrades()
{
TotalGrades = CalculateTotal();
AverageGrades = CalculateMean();
cout << "=======================================\n";
cout << "\tStudent's Grades";
cout << "\n---------------------------------------";
cout << setiosflags(ios::fixed) << setprecision(2);
cout << "\n\tEnglish: " << Marks.getEnglish();
cout << "\n\tLanguage 2: " << Marks.getSecondLng();
cout << "\n\tHistory: " << Marks.getHistory();
cout << "\n\tGeography: " << Marks.getGeography();
cout << "\n\tChemistry: " << Marks.getChemistry();
cout << "\n\tSociology: " << Marks.getSociology();
cout << "\n\tMathematics: " << Marks.getMath();
cout << "\n\tComp Sciences: " << Marks.getCompSc();
cout << "\n\tMorale: " << Marks.getMorale();
cout << "\n\tSports: " << Marks.getSports();
cout << "\n---------------------------------------";
cout << "\n\tTotal: " << TotalGrades
<< "\tMean: " << AverageGrades;
cout << "\n=======================================\n\n";
}
// This method is used to both register a student
// and enter his or her grades in one step
void StudentsIssues::ProcessStudent()
{
RegisterStudent();
ProcessGrades();
}
// This method is used to display all information
// related to a student: personal information and grades
void StudentsIssues::DisplayReport()
{
ShowStudentIdentification();
ShowStudentGrades();
}
} // namespace Students
|
#include "StudentsIssues.h"
using namespace Students;
int main()
{
StudentsIssues First;
First.ProcessStudent();
First.DisplayReport();
return 0;
}
|