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
In Python please:
Sedaia [141]

Answer:

Here is the python code:

StartingSal = int(input("Enter the starting salary: "))

AnnualIncrease = (int(input("Enter the annual % increase: ")) / 100)

Years = int(input("Enter the number of years: "))

for count in range(1,Years+1):  

   print("Year ", count, " Salary: ", StartingSal*((1+AnnualIncrease)**(count-1)))

   

Explanation:

This program prompts the user to enter starting salary, percentage increase in salary per year and number of years.

The for loop has range function which is used to specify how many times the salaries are going to be calculated for the number of years entered. It starts from 1 and ends after Years+1 means one value more than the year to display 10 too when user inputs 10 days.

The year and corresponding salary is displayed in output. At every iteration the starting salary is multiplied by annual percentage increase input by user. Here count is used to count the number of salaries per year, count-1 means it will start from 30000.

8 0
3 years ago
What is the purpose of a turbine in a power plant?
anastassius [24]
C. To make the generator work

4 0
3 years ago
Semiconductor memory is used mainly for primary storage even with its high cost. In another hand, the magnetic tape is the cheap
vodomira [7]
<span>In general you want to use the cheapest storage medium who's speed is compatible with the function it needs to perform. For active storage that's handled while running programs, you need memory whose speed is closely matched to the processor speed. And that would be the rather expensive semiconductor memory which is close to ideal for the task. But semiconductor memory has the disadvantage of being expensive and it loses the values stored when power is lost. So slower, persistent storage is used such as SSD (Solid State Drives) and hard disks. That media is cheaper, but slower, but still fast enough to handle tasks such as loading programs and data into memory for execution, or storing data generated by programs to persistent storage. But as with all man made things, disasters happen. Computers break down, hard disks crash, floods and fires happen, etc., and as a result data is lost. So we make backups. Backups have to have a lot of storage and they have to be cheap. But they don't need rapid access, you can start at the beginning and read (or write) all the way to the end. And for that purpose, magnetic tape is ideal. Magnetic tape is actually quite fast when you're simply streaming a continuous stream of data without any need to randomly access any piece of that data. And it's cheap, so you're willing to make a back up copy of your system and store that backup off site so a single disaster won't destroy both the primary system and the backup.</span>
3 0
3 years ago
Which part of a formal email is optional
EleoNora [17]
Contact information will be optional.
6 0
3 years ago
Read 2 more answers
What is DATE data type and its syntax and what is TIMESTAMP data type and its syntax in SQL language.Explain the difference betw
qaws [65]

Answer: The DATE datatype give us the particular date whereas TIMESTAMP gives us the date as well as the time as the particular moment.

Explanation:

DATE datatype gives us the date in the format yyyy-mm-dd. The timestamp format is yyyy-mm-dd hh:mm:ss. time stamp are of two types :

timestamp with time zone and timestamp without time zone.

Date is the date on that particular day whereas the timestamp is the date along with the specific time when the query is executed.

5 0
3 years ago
Other questions:
  • What provides quality education for students
    14·1 answer
  • An
    9·1 answer
  • Two-dimensional random walk (20 points). A two-dimensional random walk simulates the behavior of a particle moving in a grid of
    14·1 answer
  • Next, Leah wants to add a content slide that allows her to insert a table.
    8·2 answers
  • Scenario
    7·1 answer
  • Plz hurry it’s timed
    5·1 answer
  • Difference between switch and switch lite
    10·1 answer
  • What would be an ideal scenario for using edge computing solutions?
    6·1 answer
  • Which statement is true about the energy of electromagnetic radiation?
    15·1 answer
  • Assignment 1:
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!