Ask Question

2) Write a program c+ + to calculate students' average test scores and their grades.

You may assume the following input dа ta:

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 arrays: a one-dimensional array to store the students' names, a (parallel) two-

dimensional array to store the test scores, and a parallel one dimensional array to store

grades. Your program must contain at least the following functions: a function to read and

store data into two arrays, a function to calculate the average test score and grade, and a

function to output the results. Have your program also output the class average.

+4
Answers (1)
  1. 19 May, 16:11
    0
    The question seems to be wrong. However, if this is to be solved using the array of the class in c++. Then below program will hold good. #include

    using namespace std;

    class student

    {

    public:

    string name;

    double marks[5];

    student ()

    { int i;

    cout<>name;

    for (i=0; i<=4; i++)

    {

    cout<>marks[i];

    }

    }

    void calcavg ()

    {int i;

    double sum=0.0;

    for (i=0; i<=4; i++)

    {

    sum+=marks[i];

    }

    cout<< "avg = "<
    }

    void calcgrade ()

    {

    string grade;

    double sum=0.0;

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

    {

    sum+=marks[i];

    }

    int a = sum/5;

    if (a>=90)

    {

    cout<<"Grade = A";

    }

    else if (a>=80 && a<=90)

    {

    cout<<"Grade=A-";

    }

    else if (a60)

    {

    cout<<"Grade=B";

    }

    else if (a<=60)

    {

    cout<<"Grade=low Work Hard";

    }

    else

    {

    cout<<"You have failed";

    }

    }

    };

    int main ()

    {

    int i;

    student st[4];

    /*for (int i=0; i<=4; i++)

    {

    st[i]. student ();

    }*/

    int j;

    cout<>j;

    st[i]. calcavg ();

    st[i]. calcgrade ();

    return 0;

    }

    And this is a proper way to solve this kind of question. Make a class, add data, and functions. Make an array of object of that class as shown in above program. You can check the above program with the data provided in the question.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “2) Write a program c+ + to calculate students' average test scores and their grades. You may assume the following input dа ta: ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers