Problem 1: Create a Student Class (worth all 100 points)
This problem will require you to create a Student class and a C++ main function to test it. The Student class will need variables for the student id, student name and an array for grades. Luckily, we know that each student will only have 10 grades, so an array with 10 elements will hold all the student’s grades.
The Student class will also need a mutator method to set the grades, and a method to calculate the average of the grades.
In the C++ main function, you will need to create two instances of the Student class for the two students, which I need averages for.
Here are the students’ grades (you can just hard code them if you want):
Student 1 95 78 26 92 27 46 89 83 78 90
Student 2 100 98 97 67 59 100 98 76 83 85
The file should be named so:
<Your User Name>A8P1.cpp
For this assignment you will only need to turn in the source file (i.e. the cpp file).
Submit the assignment in the Digital Drop Box. Please remember to label this assignment <your user name>A8P1.cpp in the Digital Drop Box.
BONUS 1: (this is optional but will give you 5pts to add to any exam or assignment grade)
Write methods that will return the student’s lowest grade and highest grade and then display them. For Example:
Student Lowest Highest
--------------------------------------------------
1 26 95
2 59 100
My Work
Expand|Select|Wrap|Line Numbers
- #include "stdafx.h"
- #include "employee.h"
- Student::Student( )
- {
- setStudentNumber( 0 );
- setStudentName( "Suzie Cue" );
- setStudentsgrades[ 10 ];
- }
- Student::Student( int StudentNumber, string StudentName)
- {
- setStudentNumber( StudentNumber );
- setStudentName( StudentName );
- setStudentsgrades[ Testgrades ];
- }
- double Student::ComputeAverage( double testsTaken )
- {
- double Testgrades = 0.0;
- for (int i = 0; i<testsTaken; i++)
- Testgrades += Testgrades[i];
- return Testgrades /= testsTaken;
- }
- double Student::getStudentNumber( )
- {
- return iStudentNumber;
- }
- void Student::setStudentNumber( int StudentNumber )
- {
- iStudentNumber = StudentNumber;
- }
- string Student::getStudentName( )
- {
- return this->sStudentName;
- }
- void Student::setStudentName( string StudentName )
- {
- this->sStudentName = StudentName;
- }
- double Student::getTestgrades( )
- {
- return this->dTestgrades;
- }
- void Student::setStudentsgrades( double testsTaken )
- {
- this->dTestgrades = Testgrades;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- Student student1;
- student1.setStudentNumber( 1 );
- student1.setStudentName( "Suzie Cue" );
- student1.setStudentsgrades[ 95, 78, 26, 92, 27, 46, 89, 83, 78, 90 ];
- Student student2;
- student2.setStudentNumber( 2 );
- student2.setStudentName( "Laura Ingalls" );
- student2.setStudentsgrades[ 100, 98, 97, 67, 59, 100, 98, 76, 83, 85 ];
- cout << setfill( '*' ) << setw(40) << "" << endl;
- cout << "Student Number " << Student1.getStudentNumber( ) << endl;
- cout << "\t\t" << student1.getStudentName( ) << endl;
- cout << "\t\tTest average is $ " << std::fixed << std::setprecision( 2 ) << student1.ComputeAverage[10] << endl;
- cout << setfill( '*' ) << setw(40) << "" << endl << endl;
- cout << setw(40) << setfill( '*' ) << "" << endl;
- cout << "Student Number " << std::setprecision( 0 ) << student2.getStudentNumber( )
- << endl;
- cout << "\t\t" << student2.getStudentName( ) << endl;
- cout << "\t\tTest average is $ " << std::fixed << setprecision( 2 ) << student2.Computeaverage [ 10 ] << endl;
- cout << setw(40) << setfill( '*' ) << "" << endl << endl;
- return 0;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- return 0;
- }