Hi everyone, I just need your assistance with this assignment. My program has 5
ID: 3742109 • Letter: H
Question
Hi everyone,
I just need your assistance with this assignment. My program has 5 parts (main, 2 driver files and 2 class files)
Note: What need help with? is adding 2 new tests into main.cpp and run properly through the whole program.
The tests could be like finding the lowestgrade of 3 student records or looking for the average score studentGrades. you will need to add to new functions will call in the StudentGrades.h, create it in the StudentGrades.cpp file and tests will be run in the main.cpp. Just like the first test of this program found in the main function (but with 2 or 3 student records
like a.addStudentRecord("Joe", 90)). Thank you
The following conditions are needed to be added:
Example:
adding names to the StudentGrades object is with the member function a.addStudentRecord("Joe", 90); in the main.cpp. The "Student s" variable is just for analyzing the results of your tests.
you need to add 2 or 3 records of students and compare (the tests below are just examples, you don't need to create the same tests)
Nominal test cases(EXAMPLES)
• Test 1 - Test when the number to find was in the middle of the array (numberToFind = 77).
• Test 2 - Test an adjacent number to Test 1. (numberToFind = 84).
• Test 3 - Test when the number to find is not in the list located in the middle (numberToFind = 80)
.Boundary test cases (EXAMPLES)
•Test 4 - Test when the number to find is at the start of the array (numberToFind = 45).
• Test 5 - Test when the number to find is at the end of the array (numberToFind = 96).•
Test 6 - Test when the number to find is not in the list and is the lowest (numberToFind = -1)
.• Test 7 - Test when the number to find is not in the list and is the highest (numberToFind = 10,000).
Repetition test cases:
• Test 8 - Repeat all tests to ensure the same results.
Here is my code:
(1) Main.cpp (where you need to add new tests after test 1 and add 2 or 3 student records)
#include
#include
#include "StudentGrades.h"
using namespace std;
int main()
{
StudentGrades a;
StudentGrades b; // object b will be used for the tests that require b = a;
Student s;
// Test Case 1
s = a.getStudentWithHighestGrade();
// get the student with highest grade at initialization
std::cout << "Student " << s.getName() << " has highest grade of " << s.getGrade() << std::endl;
if ((s.getName().compare("No Entry") == 0) && (s.getGrade() == 0))
// if the test case is meet then Pass
std::cout << "Test Case 1 Passes" << std::endl;
else // else test case fails
std::cout << "Test Case 1 Fails" << std::endl;
// Test Case 2
}
(2) Student.cpp
#include
#include
#include "Student.h"
using namespace std;
Student::Student()
{
}
Student::Student(std::string n, int g) : name(n), grade(g)
{}
Student::~Student()
{}
void Student::setName(std::string name)
{
this->name = name;
}
void Student::setGrade(int g)
{
grade = g;
}
std::string Student::getName() const
{
return name;
}
int Student::getGrade() const
{
return grade;
}
(3) Student.h
#include
#include
using namespace std;
#ifndef STUDENT_H
#define STUDENT_H
class Student
{
public:
Student(); // default constructor
Student(std::string n, int g); // constructor
~Student(); // destructor
void setName(std::string name); // mutator function
void setGrade(int g); // mutator function
std::string getName() const; // accessor function
int getGrade() const; // accessor function
private:
std::string name;// holds the student name
int grade;// holds the student grage
};
#endif
(4) StudentGrades.cpp (where you new functions for the tests)
#include
#include
using namespace std;
#ifndef STUDENT_H
#define STUDENT_H
class Student
{
public:
Student(); // default constructor
Student(std::string n, int g); // constructor
~Student(); // destructor
void setName(std::string name); // mutator function
void setGrade(int g); // mutator function
std::string getName() const; // accessor function
int getGrade() const; // accessor function
private:
std::string name;// holds the student name
int grade;// holds the student grage
};
#endif
(5) StudentGrades.h (where you call the function for the tests)
#include
#include
#include "Student.h"
#ifndef STUDENTGRADES_H
#define STUDENTGRADES_H
class StudentGrades
{
public:
StudentGrades(); // default constructor
~StudentGrades(); // destructor
Student getStudentWithHighestGrade() const; // accessor function
void addStudentRecord(std::string name, int grade);
void resetList();
private:
const static int MAX_STUDENTS = 5;
int numberOfStudents;
Student *students;
};
#endif
I appreciate your help. implement all four files, add at least 2 or 3 new tests and show your output with modified code. Thank you
Explanation / Answer
// Hi. I have gone through you problem. This is what i found
// Your StudentGrade class have this function .....getStudentWithHighestGrade()....it implies grade class object must hold multiple student object.
// Just reply me through comment whether you want to store multiple student in a single StudentGrades Class Object.
// I have almost finished with solution. I will update it with one of the point above.
// Thank You.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.