Write a program that takes five students' quizzes in a course. Consider each student has given ten quizzes. Find  Best student Worst student Average student

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please check it and if it is wrong then give me a true solution.

Must focus on the average part.

 

Write a program that takes five students' quizzes in a course. Consider each student has given ten quizzes. Find 

  1. Best student
  2. Worst student
  3. Average student

 

Solution:

#include <iostream>

int stu=5,quiz=10;

struct numbers

{

    double students[5][10];

    double average1[5];

    double sumOfValues[5];

    double best1=0;

}num;

using namespace std;

void best();

void worststudent();

void average();

 

int main()

{

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

    {

        cout<<endl<<"Enter student "<<i+1<<" data :"<<endl;

        for(int j=0;j<quiz;j++)

        {

            cout<<"Quiz "<<j+1<<" numbers : ";

            cin>>num.students[i][j];

            cin.ignore();

        }

    }

    best();

    worststudent();

    average();

    return 0;

}

void best()

{

    int best=0,o,p;

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

    {

        for(int j=0;j<quiz;j++)

        {

            if(best<num.students[i][j])

            {

                best=num.students[i][j];

                o=i;p=j;

            }

        }

    }

    cout<<endl<<"Student "<<o+1<<" has best marks "<<num.students[o][p]<<" in quiz "<<p+1;

    num.best1=num.students[o][p];

}

void worststudent()

{

 

    int worststudent1,k,u;

    for(int q=0 ;q<stu;q++)

    {

        for(int w=0;w<quiz;w++)

        {

            if(worststudent1>num.students[q][w])

            {

                worststudent1 =num.students[q][w];

                k=q;u=w;

            }

        }

    }

    cout<<endl<<endl<<"Student "<<k+1<<" has worst marks "<<num.students[k][u]<<" in quiz "<<u+1;

}

void average ()

{

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

        {

                for (int j = 0; j < quiz; ++j)

                {

                    num.sumOfValues[i] += num.students[i][j];

                }

        }

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

        {

 

                int * newArray = new int [stu*quiz];

                num.average1[i] =  (num.sumOfValues[i]) / (10 * ((stu*quiz)));

                num.average1[i] *= 100;

 

        }

        int p=0;

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

        {

            if(num.average1[i]<num.average1[(i+1)%2]&&num.average1[i]>num.average1[(i-1)%2])

            {

                p=i;

            }

        }

        cout<<endl<<endl<<"Student "<<p+1<<" is the  Average ( "<<num.average1[p]<<"%) student .";

 

 

                 }

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY