vendredi 27 mars 2020

School Management Simple C++ Project [closed]

I have an exercise on structures. Here is the statement:

Write a program in C++ that contains the following operations:

Define a structure type to represent a student with the fields

last name, first name

Date of birthday

the average of grades per semester(for storage, use an 8-element tab of type reels)

course

group.

Question: write a function that displays the name of the student with the highest average of each course.

I need help thanks in advance this fonction is not working: void checkTheHeighMark(student Univ[], int AmOfStu) { double sum1=0, sum2=0, sum3=0, sum4=0, ppt1, ppt2, ppt3, ppt4, moy1, moy2, moy3, moy4; int indice1=0, indice2=0, indice3=0, indice4=0; int a=0,b=0,c=0,d=0; bool k1, k2, k3, k4; sum1 = 0;sum2 = 0;sum3 = 0;sum4 = 0; k1 = 0;k2 = 0;k3 = 0;k4 = 0; for (int i = 0; i < AmOfStu; i++) { for (int j = 0; j < 8; j++) { if (Univ[i].course == 1) { sum1 += Univ[i].GR.grades[j]; k1 = 1; a++; } if (Univ[i].course == 2) { sum2 += Univ[i].GR.grades[j]; k2 = 1; b++; } if (Univ[i].course == 3) { sum3 += Univ[i].GR.grades[j]; k3 = 1; c++; } if (Univ[i].course == 4) { sum4 += Univ[i].GR.grades[j]; k4 = 1; d++; } } if (k1) { moy1 = sum1 / 8; Univ[i].average1 = moy1; } if (k2) { moy2 = sum2 / 8; Univ[i].average2 = moy2; } if (k3) { moy3 = sum3 / 8; Univ[i].average3 = moy3; } if (k4) { moy4 = sum4 / 8; Univ[i].average4 = moy4; } } if (k1) { ppt1 = 1.0; for (int i = 0; i < a; i++) { if (Univ[i].average1 >= ppt1){ ppt1=Univ[i].average1; indice1 = i; } } cout << "student " << Univ[indice1].name << endl; cout << "heigh mark " << Univ[indice1].average1<<endl; } if (k2) { ppt2 = 1.0; for (int i = 0; i < b; i++) { if (Univ[i].average2 >= ppt2){ ppt2=Univ[i].average2; indice2 = i; } } cout << "student " << Univ[indice2].name << endl; cout << "heigh mark " << Univ[indice2].average2<<endl; } if (k3) { ppt3 = 1.0; for (int i = 0; i < c; i++) { if (Univ[i].average3 >= ppt3){ ppt3=Univ[i].average3; indice3 = i; } } cout << "student " << Univ[indice3].name << endl; cout << "heigh mark " << Univ[indice3].average3<<endl; } if (k4) { ppt4 = 1.0; for (int i = 0; i < d; i++) { if (Univ[i].average4 >= ppt4){ ppt4=Univ[i].average4; indice4 = i; } } cout <<"student " << Univ[indice4].name << endl; cout << "heigh mark " << Univ[indice4].average4<<endl; } }

Aucun commentaire:

Enregistrer un commentaire