Question

In: Computer Science

/* The following function receives the class marks for all student in a course and compute...

/*
The following function receives the class marks for all student in a course and compute standard deviation. Standard deviation is the average of the sum of square of difference of a mark and the average of the marks. For example for marks={25, 16, 22}, then average=(25+16+22)/3=21. Then standard deviation = ((25-21)^2 + (16-21)^2+(22-21)^2)/3.
Implement the function bellow as described above. Then write a test console app to use the function for computing the standard deviation of a list of marks that user inputs as floats in the range of 0.f to 100.f. User signals end of the list by entering -1 as final mark. Make sure to verify user input marks are valid and in the range, before processing them.

*/

float ComputeMarksStandardDeviation(std::array<float> marks)
{
}

Solutions

Expert Solution

PROGRAM:

#include<iostream>

#include<vector>

#include<math.h>

using namespace std;

/**The following function receives the class marks

* for all student in a course and compute standard deviation.

* function for computing the standard deviation of a list of

* marks that user inputs as floats in the range of 0.f to 100.f.*/

float ComputeMarksStandardDeviation(std::vector<float> marks){

float sum = 0;

float MarksStandardDeviation;

// find the size of the vector

int n = marks.size();

// calculate the sum of all marks

for(int i=0; i<n; i++){

sum+=marks[i];

}

/**For example for marks={25, 16, 22}, then average=(25+16+22)/3=21. Then

* standard deviation = ((25-21)^2 + (16-21)^2+(22-21)^2)/3.

* calculate the average of marks*/

float average = sum/n;

// calculate the standard deviation

for(int i=0; i<n; i++){

MarksStandardDeviation += pow(marks[i] - average, 2);

}

// return the standard deviation

return MarksStandardDeviation/n;

}

// main() function

int main()

{

float num;

vector<float> marks;

while(true){

cout<<"Enter marks: ";

cin>>num;

// User signals end of the list by entering -1 as final mark.

if(num==-1) break;

// Make sure to verify user input marks are valid and in the range,

// between 0-100f

while(num<0 || num>100){

cout<<"Out of range"<<endl;

cout<<"Enter marks between 0-100: ";

cin>>num;

}

// push_back into the vector marks

marks.push_back(num);

}

// calling and print the standard Deviation

// Standard deviation is the average of the sum

// of square of difference of a mark and the average of the marks

cout<<"Standard Deviation: "<<ComputeMarksStandardDeviation(marks);

return 0;

}

OUTPUT :
Enter marks : 25
Enter marks : 16
Enter marks : 22
Enter marks : -1
Standard deviation : 14


Related Solutions

use c++ /* The following function receives the class marks for all student in a course...
use c++ /* The following function receives the class marks for all student in a course and compute standard deviation. Standard deviation is the average of the sum of square of difference of a mark and the average of the marks. For example for marks={25, 16, 22}, then average=(25+16+22)/3=21. Then standard deviation = ((25-21)^2 + (16-21)^2+(22-21)^2)/3. Implement the function bellow as described above. Then write a test console app to use the function for computing the standard deviation of a...
***Given a class called Student and a class called Course that contains an ArrayList of Student....
***Given a class called Student and a class called Course that contains an ArrayList of Student. Write a method called dropStudent() as described below. Refer to Student.java below to learn what methods are available.*** Course.java import java.util.*; import java.io.*; /****************************************************** * A list of students in a course *****************************************************/ public class Course{ /** collection of Students */ private ArrayList<Student> roster; /***************************************************** Constructor for objects of class Course *****************************************************/ public Course(){ roster = new ArrayList<Student>(); } /***************************************************** Remove student with the...
Language C++ Student-Report Card Generator: create a class called student and class called course. student class...
Language C++ Student-Report Card Generator: create a class called student and class called course. student class this class should contain the following private data types: - name (string) - id number (string) - email (s) - phone number (string) - number of courses (int) - a dynamic array of course objects. the user will specify how many courses are there in the array. the following are public members of the student class: - default constructor (in this constructor, prompt the...
In order to access this course, attend this class as an on-line student, and participate in...
In order to access this course, attend this class as an on-line student, and participate in class discussions, you need to use a specific course management system. Answer the following questions about this system. 1. What is the name of the course management system? 2. Who created this system? 3. Other than your instructor, name three ways to get technical help with this product. 4. Other than class discussions, talk about one function of this product. Define its purpose and...
Define and implement class Course. This class should contain the following fields: course name, course description,...
Define and implement class Course. This class should contain the following fields: course name, course description, department, time the course starts, weekday the course is held on (for simplicity, let us assume the course only meets once a week). This class should contain getters and setters for all its attributes. This class also needs at least one constructor. Save this class and its definition into a file named Course.java. Define and implement class Student. This class should contain the following...
C++ Write the implementation of the function concatenateIntArrays. This function receives 4 parameters in the following...
C++ Write the implementation of the function concatenateIntArrays. This function receives 4 parameters in the following order: An array of integer values (array1). An integer representing the size of array1 (size1). An array of integer values (array2). An integer representing the size of array2 (size). The function creates a dynamic array of integers of size size1+size2 to store all the values in array1, followed by all the values in array2. The function returns the pointer used to create the dynamic...
Write a function which receives a list and returns a number. In the list, all numbers...
Write a function which receives a list and returns a number. In the list, all numbers have been repeated twice except one number that is repeated once. The function should return the number that is repeated once and return it.write a python program for this question. use main function.
Compute the expenditure function for the perfect complements utility function. Then compute the expenditure function for...
Compute the expenditure function for the perfect complements utility function. Then compute the expenditure function for the perfect substitutes utility function. Do your results make sense?
Write a class encapsulating the concept of a Student, assuming that the Student has the following...
Write a class encapsulating the concept of a Student, assuming that the Student has the following attributes: the name of the student, the average of the student, and the student’s GPA. Include a default constructor, an overloaded constructor, the accessors and mutators, and methods toString() and equals(). Also include a method returning the letter grade base on the following range for the average: Average Range Letter Grade 90-100 A 85-89   B+ 80-84 B 75-79 C+ 70-74 C 65-69 D+ 60-64...
Write a class encapsulating the concept of a Student, assuming that a student has the following...
Write a class encapsulating the concept of a Student, assuming that a student has the following attributes: last name, first name, id, array of grades. Include a constructor, the accessors and mutators, and method toString. Also code the following methods: one returning the GPA using the array of grades (assuming each grade represents a course grade and all courses have the same number of credit hours) and a method to add a course grade to the array of grades (this...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT