Here\'s the problem. Any help would be appreciated. Even just starting with hint
ID: 3627234 • Letter: H
Question
Here's the problem. Any help would be appreciated. Even just starting with hints on one of the public functions would be nice. Thanks!CS 1410
Object Oriented Programming Using C+
Student Statistics
Create an input file that will contain each student’s name and raw score. Write a program that will read this information (use the end of file method to terminate reading) into two parallel arrays. First compute the class average, then compute the standard deviation from the class average. Finally, compute the median ( middle score by position). Finally, compute the highest score, the lowest score and the range (difference between the highest and lowest score).
The method for computing the standard deviation is as follows: For each student, compute the difference between the student’s raw score and the class average. Then the standard deviation is
the square root of the following expression:
( sum of squares of differences) / (class size)
For example, if the grades were 70, 74, 80, 82, 68 and 76, the average would be 75.0, and the standard deviation would be the square root of the following expression:
(70-75)2 + (74-75)2 + (80 - 75)2 + (82 - 75)2 + (68 - 75)2 + (76 - 75)2
________________________________________________________
6
The median is defined to be the middle score by position after the scores have been sorted or put into sequence. For example, if five sorted scores were 22, 33, 44, 55 and 99, then the median would be the middle score or the score in the 3rd position which is 44. If there are an even number of scores, the median is the average of the two middle scores. For example, if six sorted scores were 11, 33, 44, 55, 77 and 99, the median would be the average of the 3rd and 4th scores which would be (44 + 55) / 2 which is 49.50. The median function should invoke a function that implements the bsort() function logic of Chapter 10 (or something similar) which will sequence the array of scores. Keep the names parallel to the scores by swapping the same positions in the Names array as you do in the Scores array.
The output should contain (1) a list with each student’s name and numerical score (names should be left justified and scores right justified in columns); and (2) the class average, standard deviation median, high score, low score and range (each with 2 decimal places).
Store the names and scores into separate parallel arrays. Code separate functions to input the data, calculate the average, calculate the standard deviation, sort the scores, calculate the median, calculate the high score/low score/range and output all results. Use only pointer notation for accessing both the Names and Scores arrays.
Run your program twice – once for each input data file provided by the instructor. Print the student information (Name and Score ) in descending order by Score, one student per line. Label all output clearly.
Define a ‘StudentStat’ class as follows:
class StudentStat
{
private:
int Size ;
string Names [ 20 ] ;
int Scores [ 20 ] ;
float Avg,
StDev,
Median ;
int High_Score,
Low_Score,
Range;
void Sortem ( ) ;
public:
void Input ( ) ;
void Calc_Avg ( ) ;
void Calc_StDev ( ) ;
void Calc_Median ( ) ;
void Calc_Range( ) ; // also calculates the high and low score
void Output ( ) ;
} ;
In the main program, declare an object as follows: StudentStat Studobj ;
Invoke the member functions as needed for the object.
Submit the .cpp file and the two output files that are created by running your program twice, once using prog8even.dat and once using prog8odd.dat data file.
Explanation / Answer
//include header files
#include<iostream.h>
#include<iomanip.h>
#include<fstream.h>
#include<math.h>
//class creation
class StudentStat
{
private:int Size;
char *Name;
int Score[10];
float Avg;
StudentStat::Calc_StdDeviation(int marks,float ave)
{
float stddev=0;
for(i=0;i<6;i++)
{
stddev+=(marks[i]-ave)*(marks[i]-ave);
}
stddev=sqrt(stddev);
}
StudentStat::Calc_Range(int array,float stddev)
{
int high,low,range;
float median;
// bubble sort the elments in the array
for(i=0;i<6;i++)
{
for(int j=0;j<6;j++)
{
if(array[i]>array[i+1])
{
int temp;
temp=array[i];
array[i]=array[i+1];
array[i+1]=temp;
}
}// end of inner loop
}// end of for outer loop
low=array[0];
high=array[5];
//since n =6
median =(a[3]+a[4])/2;
//Range of elements
range=high-low;
output(range,stddev,median);
}
StudentStat::output(int ran,float stddeviation,float median)
{
ofstream fout;
fout.open("studentStat.txt");
fout<<"Range"<<ran;
fout<<"Average"<<avg;
fout<<"standard Deviation"<<stddeviation;
fout<<"Median"<<median;
fout.close();
}