Question

In: Computer Science

Write a C++ program to input 10 scores (range from 0-100), calculate the average, then display...

Write a C++ program to input 10 scores (range from 0-100), calculate the average, then display the student's name, and a letter grade such as A, B, C, D, or F. It shall have a Student class with necessary private data members and constructor and public methods, such as getName, getGrade, calcScore, convertToGrade, etc. Try to create a Student object in main(), then invoke its methods to perform the tasks.

Solutions

Expert Solution

#include <iostream>

using namespace std;

#define MAX 10

class student

{

private:

char name[30];

int total=0;

float avg,score[10];

char grade;

public:

void getName(void);

  

void getGrade(void);

  

void calcScore(void);

  

void convertToGrade(void);

};

//member function definition, outside of the class

void student::getName(void){

cout << "Enter name: " ;

cin >> name;}

void student::calcScore(void){

cout << "Enter total marks out of 100: ";

for(int i=0;i<10;i++)

cin >> score[i];

for(int i=0;i<10;i++)

total=total+score[i];

avg=(float)total/100*100;

}

void student::convertToGrade(void)

{

if(avg<=)

grade='F';

else if((avg>)&&(avg<=))

grade='E';

else if((avg>)&&(avg<=))

grade='D';

else if((avg>)&&(avg<=))

grade='C';

else if((avg>)&&(avg<=))

grade='B';

else if((avg>))

grade='A';

}

void student::getGrade(void){

cout << "Student details:\n";

cout << name <<" "<<grade;

}

int main()

{

student std[MAX];   

int j;

for(j=0;j< 10; j++){

std[j].getName();

std[j].calcScore();

std[j].convertToGrade();

}

cout << endl;

  

for(j=0;j< 10; j++){

cout << "Details of student " << (j+1) << ":\n";

std[j].getGrade();

}

return 0;

}

-> In the case where grade is alloted in the converttograde function

i have left the limits for you to have them as you desire . As you have not mentioned for what range what grades should be alloted. So you can have them edited as you want. Otherwise everything is as desired.

#you can ask if any doubt persists..


Related Solutions

C++ Write a program that reads in a list of 10 names as input from a...
C++ Write a program that reads in a list of 10 names as input from a user and places them in an array. The program will prompt for a name and return the number of times that name was entered in the list. The program should output total number of instances of that name and then prompt for another name until the word done is typed in. For this lab, use the string data type as opposed to char to...
Write a program in java that uses methods to input data for calculation, calculate, and display...
Write a program in java that uses methods to input data for calculation, calculate, and display the results of the calculations. That is, there are at least three methods. The problem is to write a program that calculates the area of a rectangle. This action should be repeatable.
For this C++ program, Write and modify the code to compute and display the class average...
For this C++ program, Write and modify the code to compute and display the class average as well as the standard deviation. Your code changes are as follows: 1. The variable “double grade” should be replaced by a two-dimensional array variable “double grade[NUMSTUDENTS][NUMGRADES].” Also replace the variable “double average” by “double average[NUMSTUDENTS].” This is necessary since you need to save the entered grades specially to compute the standard deviations. 2. After completing the display of the average grade of all...
Write a program that reads a file consisting of students’ test scores in the range 0–200....
Write a program that reads a file consisting of students’ test scores in the range 0–200. It should then determine the number of students having scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200. Output the score ranges and the number of students. (Run your program with the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200,...
Write a C++ program that reads a file consisting of students’ test scores in the range...
Write a C++ program that reads a file consisting of students’ test scores in the range 0–200. It should then determine the number of students having scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200. Output the score ranges and the number of students. (Run your program with the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176,...
#C. Write a program that accepts any number of homework scores ranging in value from 0...
#C. Write a program that accepts any number of homework scores ranging in value from 0 through 10. Prompt the user for a new score if they enter a value outside of the specified range. Prompt the user for a new value if they enter an alphabetic character. Store the values in an array. Calculate the average excluding the lowest and highest scores. Display the average as well as the highest and lowest scores that were discarded.
Write a program that accept an integer input from the user and display the least number...
Write a program that accept an integer input from the user and display the least number of combinations of 500s, 100s, 50s, 20s, 10s, 5s, and 1s. Test your solution using this samples] a. Input: 250 Output: 1x200s, 1x50s b. Input: 1127 Output: 5x200s, 1x100s, 1x20s, 1x5s, 2x1s c. Input: 1127 Output: 5x200s, 1x100s, 1x20s, 1x5s, 2x1s d. Input: 19 Output: 1x10s, 1x5s, 4x1s ​[Hints] o Use division to determine the number of occurrence of each element (i.e. 200, 100)...
If I create a frequency table summarizing anxiety scores that range from 0 to 100, what...
If I create a frequency table summarizing anxiety scores that range from 0 to 100, what is the best number of "bins" to use in the table? Group of answer choices a)10 b.)100 c)20 d)4 After taking a defensive driving course, most student drivers did very well on the driver's license exam by passing the test with 75% or higher. How would you describe the distribution of the exam scores? Group of answer choices a)The distribution is left skewed. b)The...
Write a program that calculates the average of upto 100 English distances input by the user....
Write a program that calculates the average of upto 100 English distances input by the user. Create an array of objects of the Distance class, as in the ENGLARAY example in this chapter. To calculate the average, you can borrow the add_dist() member function from the ENGLCON example in Chapter 6. You’ll also need a member function that divides a Distance value by an integer. Here’s one possibility: void Distance::div_dist(Distance d2, int divisor) { float fltfeet = d2.feet + d2.inches/12.0;...
Use c++ programming Construct an array of 1000 random integers within range [0, 100] An input...
Use c++ programming Construct an array of 1000 random integers within range [0, 100] An input file input.txt is provide. Each line of input.txt is a query integer that you need to check how many of that number is in your random integer array. For each query integer, fork a new child process to do the counting. The output is for each input query, output the count and child process id. For example: $> query: 13 count: 5 pid: 13342...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT