Question

Create a C++ program to calculate grades as well as descriptive statistics for a set of...

Create a C++ program to calculate grades as well as descriptive statistics for a set of test scores. The test scores can be entered via a user prompt or through an external file. For each student, you need to provide a student name (string) and a test score (float). The program will do the followings:

Assign a grade (A, B, C, D, or F) based on a student’s test score.

Display the grade roster as shown below:

Name      Test Score     Grade

Kyle            90                   A

Matt            100                 A

Carl             93                   A

Calculate the following descriptive statistics:

Number of students in the class

Average score

Maximum score

Minimum score

Output example:

Number of students in the class: 3

Class Average: 94.3333

Maximum Test Score: 100

Minimum Test Score: 90

The program must use:

A loop structure (for-loop, while-loop, or do-while-loop)

Conditional processing (if-then-else)

Arrays

Classes and objects (separate theclass interface from the implementations)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Given below is the code for question. Please do rate the answer if it helped. Thank you.

student.h
--------
#ifndef STUDENT_H
#define STUDENT_H
#include
using namespace std;

class Student{
private:
string name;
double score;
public:
Student();
Student(string name1, double score1);
string getName();
double getScore();
char getGrade();
void setName(string s);
void setScore(double s);
};
#endif

student.cpp
-------
#include "student.h"
#include
using namespace std;

Student::Student(){
score = 0;
}

Student::Student(string name1, double score1){
name = name1;
score = score1;
}
void Student::setName(string s){
name = s;
}

void Student::setScore(double s){
score = s;
}
string Student::getName(){
return name;
}
double Student::getScore(){
return score;
}
char Student::getGrade(){
if(score >= 90)
return 'A';
else if(score >= 80)
return 'B';
else if(score >= 70)
return 'C';
else if(score >= 60)
return 'D';
else
return 'F';
}


student_main.cpp
-----
#include
#include
#include "student.h"
using namespace std;

int main(){
const int SIZE = 10;
Student s[SIZE];
int count = 0;
string choice;
string name;
double score;
double max, min, avg;

//input
do{
cout << "Enter name: ";
getline(cin, name);
cout << "Enter score: ";
cin >> score;
s[count].setName(name);
s[count].setScore(score);
count++;

cout << "Want to add another? (y/n): ";
cin >> choice;
cin.ignore(); //get rid of newline

}while(count < SIZE && ( choice == "y" || choice == "Y"));

max = min = s[0].getScore();
avg = 0;

for(int i = 0; i < count; i++){
if(s[i].getScore() > max)
max = s[i].getScore();
else if(s[i].getScore() < min)
min = s[i].getScore();
  
avg += s[i].getScore();
}

avg /= count;


cout << left << setw(15) << "Name" << setw(15) << "Score" << setw(15) << "Grade" << endl;

for(int i = 0; i < count; i++){
cout << setw(15) << s[i].getName() << setw(15) << s[i].getScore() << setw(15) << s[i].getGrade() << endl;
}

cout << endl;
cout << "Number of students: " << count << endl;
cout << "Class average: " << avg << endl;
cout << "Maximum score: " << max << endl;
cout << "Minimum score: " << min << endl;
return 0;
}

Enter name: Kyle Enter score: 90 Want to add another? (y/n): y Enter name: Matt Enter score: 100 Want to add another? (y/n):

Add a comment
Know the answer?
Add Answer to:
Create a C++ program to calculate grades as well as descriptive statistics for a set of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in C++ Create a program that will calculate a student’s grade average of 5 test scores...

    in C++ Create a program that will calculate a student’s grade average of 5 test scores and assign a letter grade for a student. The program should use a class to store the student’s data including the student’s name and score on each of 5 tests. The program should include member functions to 1) get the student’s test scores, 2) calculate the average of the test scores, and 3) display the results as follows: Test scores for Mary: 100 90...

  • Java Program: In this project, you will write a program called GradeCalculator that will calculate the...

    Java Program: In this project, you will write a program called GradeCalculator that will calculate the grading statistics of a desired number of students. Your program should start out by prompting the user to enter the number of students in the classroom and the number of exam scores. Your program then prompts for each student’s name and the scores for each exam. The exam scores should be entered as a sequence of numbers separated by blank space. Your program will...

  • In this assignment, you will write a program in C++ which uses files and nested loops...

    In this assignment, you will write a program in C++ which uses files and nested loops to create a file from the quiz grades entered by the user, then reads the grades from the file and calculates each student’s average grade and the average quiz grade for the class. Each student takes 6 quizzes (unknown number of students). Use a nested loop to write each student’s quiz grades to a file. Then read the data from the file in order...

  • Write a complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

  • [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and...

    [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and methods must be used for this program. Process: •Read the number of students in a class. Make sure that the user enters 1 or more students. •Create an array with the number of students entered by the user. •Then, read the name and the test score for each student. •Calculate the best or highest score. •Then, Calculate letter grades based on the following criteria:...

  • c++ Instructions Overview In this programming challenge you will create a program to handle student test...

    c++ Instructions Overview In this programming challenge you will create a program to handle student test scores.  You will have three tasks to complete in this challenge. Instructions Task 1 Write a program that allocates an array large enough to hold 5 student test scores. Once all the scores are entered, the array should be passed to a function that sorts them in ascending order. Another function should be called that calculates the average score. The program should display the...

  • Write a c++ program which uses a structure having the indicated member names to store the...

    Write a c++ program which uses a structure having the indicated member names to store the following data: Name (student name) IDnum (student ID number) Tests (an array of three test scores) Average (average test score) Grade (course grade) The program will keep a list of three test scores for one student. The program may prompt the user for the name, ID number, and test scores, or these may be assigned within the program. The average test score will be...

  • please use the c language Assignment 12 The program to write in this assignment is a...

    please use the c language Assignment 12 The program to write in this assignment is a program that calculates score statistics and manages the grades of the students. First, the student list and are given in a file named "student.dat" as in the following: 이성우 77 홍길동 88 scores 201 1710086 2012700091 This program reads the input file "student.dat" and keeps this data in a linear linked list. Each node must be a struct which contains the following: student id...

  • C++: Create a grade book program that includes a class of up to 20 students each...

    C++: Create a grade book program that includes a class of up to 20 students each with 5 test grades (4 tests plus a Final). The sample gradebook input file (CSCI1306.txt) is attached. The students’ grades should be kept in an array. Once all students and their test scores are read in, calculate each student’s average (4 tests plus Final counts double) and letter grade for the class. The output of this program is a tabular grade report that is...

  • Write a program to calculate students’ average test scores and their grades. You may assume the...

    Write a program to calculate students’ average test scores and their grades. You may assume the following data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT