C Coding question Write a class called Student that has two

C++ Coding question;

Write a class called Student that has two data members - a string variable called name and a double variable called score. It should have a constructor that takes two values and uses them to initialize the data members. It should have get methods for both data members (getName and getScore), but doesn\'t need any set methods.

Write a separate function called stdDev that takes two parameters - an array of pointers to Students and the size of the array - and returns the standard deviation for the student scores (the population standard deviation that uses a denominator of N,not the sample standard deviation, which uses a different denominator).

(Note: I could have had you use an array of Students for this instead of an array of pointers to Students, but I want you to practice pointer syntax.)

The files must be named Student.hppStudent.cppand stdDev.cpp

Solution

/*
* File: Student.hpp
*/

#ifndef STUDENT_HPP
#define STUDENT_HPP

#include <iostream>
#include<cmath>
using namespace std;

class Student{
public:
Student(string,double);
string getName();
double getScore();
  
private:
string name;
double score;
  
};

#endif /* STUDENT_HPP */

/*
* File: Student.cpp
**/
#include \"Student.hpp\"
#include \"stdDev.cpp\"

Student::Student(string studentName, double studentScore){
name = studentName;
score = studentScore;
}

string Student::getName(){
return name;
}

double Student::getScore(){
return score;
}

/*
* File: stdDev.cpp
*/
#include \"Student.hpp\"
double stdDev(Student** student,int size){
double sum = 0.0, mean, standardDeviation = 0.0;

int i;

for(i = 0; i < size; ++i)
{
sum += student[i]->getScore();
}

mean = sum/size;

for(i = 0; i < size; ++i)
standardDeviation += pow(student[i]->getScore() - mean, 2);

return sqrt(standardDeviation / size);   
}

C++ Coding question; Write a class called Student that has two data members - a string variable called name and a double variable called score. It should have a
C++ Coding question; Write a class called Student that has two data members - a string variable called name and a double variable called score. It should have a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site