1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
klasskru [66]
3 years ago
12

Create a structure representing a student. The member variables should include student name, student ID, and four test grades fo

r the student (an array of four grades as a member variable). Prompt the user to enter the name, ID, and the four positive test results. Perform error checking for negative values. Store all the data in a structure object. Calculate the average of the three highest grades, dropping the lowest grade. Display the student's name, ID number, four test grades, and the average of the three highest grades. Use a loop to repeat the questions for the next student. You can recycle the same struct object for the next student. Terminate the program when the user decides to stop.
Computers and Technology
1 answer:
Neporo4naja [7]3 years ago
6 0

Answer:

Output:

Name: Brainly

ID:0001

Write the 4 tests grades of the student separated by space :10 9 8 10

Brainly

0001

10 9 8 10

Average :9.66667

'1' to continue '0' to exit :

Explanation:

#include<iostream>

#include<string>

using namespace std;

//variables declaration

struct Student {

  string id; //string declaration ID

  string name; // string declaration name

  int grades[4]; //array of 4 because it is 4 grades

};

//definition of the function get information

void inputData(Student &s){

 

   

   cout << "Name:" ;

   getline(cin,s.name);

   cout << "ID:";

   cin >> s.id;

   cout << "Write the 4 tests grades of the student separated by space :";

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

       cin >> s.grades[i];

}

//definition of the function of average

double inputAvg(Student s){

   double summation;

   int temporary;

   double average;

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

      for (int j = i; j<4; j++){

         if (s.grades[j] > s.grades[i]){

             temporary = s.grades[i];

             s.grades[i] = s.grades[j];

             s.grades[j] = temporary;

         }

      }

    }

    summation = 0;

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

        summation = summation + s.grades[i];  

    }

    average = summation/3;

    return average;

}

void disp(Student *s){

   cout << s->name << endl;

   cout << s->id << endl;

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

       cout << s->grades[i] << " ";

   cout << endl;

   cout << "Average :" << inputAvg(*s) << endl;

   

}

int main(){

  Student st;

  int ch;

  while(true){

      inputData(st);

      disp(&st);

      cout << " '1' to continue '0' to exit :";

      cin >> ch;

      if (ch == 0)

         break;      

  }

  return 0;

}

You might be interested in
How do you change colors for presentation to blue warm in power point?
Furkat [3]

In PowerPoint presentations you can change background color. The best way to do this is to change the template background color in the master view. This will let you use the same background color among the whole presentation and also for the new slides that you will create.

In order to change the background color in Microsoft PowerPoint 2010 we need to go to View and Slide Master. Then, right click on the first slide and click Format Background.

5 0
3 years ago
What is the name of the unique identifier assigned to any personal computer that is connected to the internet?
Stolb23 [73]
There is no truly unique identifier assigned to a PC. Any appearance of a unique ID is merely an illusion. The closest thing there is to a unique identifier is a MAC address, which is actually assigned to a network adapter (Ethernet port, wireless radio, etc.) and is usually unique but can be faked
7 0
3 years ago
It's so eazy
Dmitrij [34]

Answer:

  1. true
  2. true
  3. false
  4. true
  5. true
4 0
3 years ago
Read 2 more answers
Which statement best describes one reason why assembly
posledela

Answer:

D. It allows programmers to write abbreviations instead of repeating calculations

7 0
2 years ago
In which decade did cell phones become available to the public?
JulijaS [17]

Answer:

1980s

Explanation:

Source:

https://www.cbc.ca/news/technology/5-major-moments-in-cellphone-history-1.1407352

6 0
3 years ago
Other questions:
  • Find functions f1 and f2 such that both f1 and f2 are O(g(n)), but f1(n) is not O(f2)
    6·1 answer
  • Assume that the myname.txt file is currently closed. write the code segment that opens the file without erasing it, write anothe
    13·1 answer
  • What is considered Tim Berners-Lee's greatest contribution to the World Wide Web?
    5·1 answer
  • List three things that sally sue can improve
    12·2 answers
  • The number 1 represent what state in binary code
    9·1 answer
  • Many interesting science-, technology-, engineering-, and math-oriented websites provide open-source data to the public. Which o
    8·1 answer
  • How do I change my name on my Brainly Profile?
    15·2 answers
  • The cost of a postsecondary education increases with the length of time involved in the program.
    10·1 answer
  • 15. You read a news article that's politically biased and not well organized. It's
    6·1 answer
  • What are the different types of topology?​ in details
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!