Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

First, create and copy the below data (not the captions) into a file name Refere

ID: 3601221 • Letter: F

Question

First, create and copy the below data (not the captions) into a file name Referees.dat

ID            FName LName                  Grade                  

0001       Mike      Apple                    CLUB                    

0012       Josh       Boeing                  STATE                   
0103       Linda     Intel                       STATE                   
0084       John      Rambus                  NATIONAL         
0205       Becky    Sirius                     CLUB                    
0045       Tom       Skyworks             CLUB                    
0807       Kevin     Suzuki                   NATIONAL         
0074       Henry    Xilinx                     STATE                   

You are to write a program to do the followings:

Define an enumeration type RefereeGrade including 5 values UNKNOWN, CLUB, STATE, NATIONAL and FIFA.

Define a structure named SReferee containing data members for the following information:

·         Id (typed string)

·         First Name (typed string)

·         Last Name (typed string)

·         Grade (typed RefereeGrade)

Then, create an array of 30 elements typed SReferee to read the data from the file Referees.dat into this array.

Create a menu with the following options:

1.List all referees

2.List all referees of a specific grade

3.List all referees with grade less than a specific grade

4.List all referees with grade more than a specific grade

5.List information of a specific referee using the Id

6.List information of a specific referee using the names

7.Add a referee

8.Remove a referee using Id

9.Update referee grade using Id

10.Quit

For option Quit, before quitting your program, you have to write all referee information back to the file Referees.dat to keep the updated information of referees.

The coding language is c++ and I have to get it done by saturday so hopefully that is a good amount of time.

And if you could comment a lot so i could see what each line does, that would be great.

My teacher gave this skeleton/frame to use so if you could copy and paste it and do it from there that would be amazing:

#include <iostream>

#include <string>

using namespace std;

struct SReferee

{

// Your definition here

};

int menu ();

void listAllReferees ();

void listRefereesOfSpecificGrade ();

void listtRefereesWithGradeLessThanSpecificGrade ();

void listtRefereesWithGradeMoreThanSpecificGrade ();

void listtRefereeInfoWithId ();

void listtRefereeInfoWithNames ();

void addNewReferee ();

void removeReferee ();

void updateRefereeGrade ();

void Quit();

SReferee referees[30];

// Function to read referee information from the file Referees.dat

void readRefereeInfo();

// Function to write referee information back to the file Referees.dat

void writeRefereeInfo();

void main()

{

// Read referee information from the file Referees.dat

readRefereeInfo();

       int choice;

       do {

              system("CLS");

              choice = menu();

              switch (choice) {

              case 1:

                    listAllReferees ();

                     break;

              case 2:

                    listRefereesOfSpecificGrade ();

                     break;

              case 3:

                    listtRefereesWithGradeLessThanSpecificGrade ();

                     break;

              case 4:

                    listtRefereesWithGradeMoreThanSpecificGrade ();

                     break;

              case 5:

                    listtRefereeInfoWithId ();

                     break;

              case 6:

                    listtRefereeInfoWithNames ();

                     break;

              case 7:

                    addNewReferee ();

                     break;

              case 8:

                    removeReferee ();

                     break;

              case 9:

                    updateRefereeGrade ();

                     break;

              case 10:

                     Quit();

                     break;

              default:

                     cout<< "That was an invalid choice, please try again! ";

              }

              system("PAUSE");

       } while (choice > 0 && choice < 9);

}

int menu ()

{

       int option;

       cout<< "             REFEREE ASSIGNING SYSTEM ";

       cout<< " 1. List All Referees. ";

       cout<< " 2. List All Referees Of A Specific Grade. ";

       cout<< " 3. List All Referees With Less Than A Specific Grade. ";

       cout<< " 4. List All Referees With More Than A Specific Grade. ";

       cout<< " 5. List Referee Information With ID. ";

       cout<< " 6. List Referee Information With Names. ";

       cout<< " 7.  Add New Referee. ";

       cout<< " 8.  Remove A Referee. ";

       cout<< " 9.  Update Referee Grade. ";

       cout<< "10.  Quit. ";

       cout<< "Please select your option: ";

       cin>> option;

       while (option < 1 || option > 10)

       {

              cout<< "Invalid option!!! Please select valid option: ";

              cin>> option;

       }

       return option;

}

void listAllReferees ()

{

       cout<< "Inside listAllReferees () ";

       //Your code here

}

void listRefereesOfSpecificGrade ()

{

       cout<< "Inside listRefereesOfSpecificGrade () ";

       //Your code here

}

void listtRefereesWithGradeLessThanSpecificGrade ()

{

       cout<< "Inside listtRefereesWithGradeLessThanSpecificGrade () ";

       //Your code here

}

void listtRefereesWithGradeMoreThanSpecificGrade ()

{

       cout<< "Inside listtRefereesWithGradeMoreThanSpecificGrade () ";

       //Your code here

}

void listtRefereeInfoWithId ()

{

       cout<< "Inside listtRefereeInfoWithId () ";

       //Your code here

}

void listtRefereeInfoWithNames ()

{

       cout<< "Inside listtRefereeInfoWithNames () ";

       //Your code here

}

void addNewReferee ()

{

       cout<< "Inside addNewReferee () ";

       //Your code here

}

void removeReferee ()

{

       cout<< "Inside removeReferee () ";

       //Your code here

}

void updateRefereeGrade ()

{

       cout<< "Inside updateRefereeGrade () ";

       //Your code here

}

void Quit()

{

// Write Referee information back to the file Referees.dat

writeRefereeInfo();

       cout<< "Have a nice day ";

}

Explanation / Answer

#include <iostream>

#include <fstream>

#include <string>

#include <cstdlib>

using namespace std;

typedef struct SReferee {

string Id ;

string First_Name;

string Last_Name;

string Grade;

} S;

const int SIZE = 30;

void showChoices();

void ListReferees(SReferee arr[]);

int main()

{

SReferee arr[SIZE];

ifstream in_stream;

ofstream out_stream;

int array_size = 20;

int position = 0;

//double numbers[array_size];

//Check input and output file.

in_stream.open("C:/Users/SAHANUR/Documents/CheggProgramsCpp/Referees.dat"); //Full path of the file

//in_stream.open("C:/Users/SAHANUR/Documents/CheggProgramsCpp/A.dat");

if (in_stream.fail())

{

cout << "Input file opening failed";

exit(1);

}

//array to read data from array as long as we dont reach the end of file marker

while (position < array_size && in_stream >> arr[position].Id && in_stream >> arr[position].First_Name

&& in_stream >> arr[position].Last_Name && in_stream >> arr[position].Grade)

{

cout << position << " = "

<< arr[position].Id << " "

<< arr[position].First_Name<< " "

<< arr[position].Last_Name << " "

<< arr[position].Grade<< " "<< endl;

position++;

}

int choice;

do

{

showChoices();

cin >> choice;

switch (choice)

{

case 1:

ListReferees(arr);

break;

case 2:

break;

case 3:

break;

case 4:

break;

case 5:

break;

case 6:

break;

case 7:

break;

case 8:

break;

case 9:

break;

case 10:

break;

default:

cout << "Invalid input" << endl;

}

}while (choice != 10);

return 0;

}

void showChoices()

{

cout << "MENU" << endl;

cout << "1. List all referees" << endl;

cout << "2. List all referees of a specific grade" << endl;

cout << "3. List all referees with grade less than a specific grade " << endl;

cout << "4. List all referees with grade more than a specific grade " << endl;

cout << "5. List information of a specific referee using the Id" << endl;

cout << "6. List information of a specific referee using the names" << endl;

cout << "7. Add a referee" << endl;

cout << "8. Remove a referee using Id" << endl;

cout << "9. Update referee grade using Id" << endl;

cout << "10. Quit" << endl;

cout << "Enter your choice :";

}

void ListReferees(SReferee arr[]){

int n=sizeof(arr) ;

//int n=sizeof(arr[0]);

int i=0;

cout << " All Referees " <<n;

for(i=0;i<n;i++){

cout << arr[i].Id << " "

<< arr[i].First_Name<< " "

<< arr[i].Last_Name << " "

<< arr[i].Grade<< " "<< endl;

}

}