mercredi 17 octobre 2018

Matching different array information

I'm trying to look for the person who has the highest score in the class. I have a class called person also but any time I'm trying to retrieve the information is showing the information correct for the person with the highest score. However, the other information it is showing is from the last output and I need them to match with the information that was put it in at the same time, like matching the information that was entered in at the same time stored in the array.

The input is for 3 users

Also the one with the highest grade get extra points but you need to have a grade more than 80 then I have to compare who have more than 80 from the input.

int main()
{
class Person // class name

cout << "Enter persons name";

    for(int p = 0; p < 3; p++)
    {
       cout << "Name: "; 
       getline(cin, name[r]);

       cout << "Grade: ";
       cin >> grades[r];

    }


    for (int r = 0; r < SIZE; r++)
    {
       person.setName(name[p]);
       person.setGrades(grades[p]);

    if ( grades[r] >= 80)
     {
       cout << "The Person's name: " << person.getName() << "grate: " << 
               person.getGrades() << "you might get the extra points\n";
     }  

    else
     {
       cout << "The Person's name: " << person.getName() << "grate: " << 
               person.getGrades() << "you dont qualify to get the extra 
               points\n";

     }

    } 


double lucky_one= grades[0];



for (int p = 0; p < 3; p++)

{

     {

      if (grades[p] > lucky_one)

       { 

       lucky_one= grades[p];

       }

      }    


}            
   cout << lucky_one << "\n\n";

   cout << "The Person's name: " << person.getName() << "grate: " << 

               person.getGrades() << "you will get the extra points\n";


    return 0;

}

Here is where the information only get the last one that was showed so if the one with the highest score was in the 2nd input will show the right grade but wont show the last input.

Aucun commentaire:

Enregistrer un commentaire