Advertisement
RUSSELMEMPIN

Player Record (Di pa tapos)

Jan 22nd, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.20 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct PlayerRecord{
  5.     char Nickname [50];
  6.     int age;
  7.     float bestScore1;
  8.     float bestScore2;
  9.     float average;
  10. }record[5];
  11.  
  12. void AddRecord() {
  13.     PlayerRecord player;
  14.     system("cls");
  15.     for (int c = 0; c < 5; c++) {
  16.         cout << "Player " << c+1 << endl;
  17.         cout << "Enter the nickname: ";
  18.         cin >> record[c].Nickname;
  19.         cout << "Enter the age: ";
  20.         cin >> record[c].age;
  21.         cout << "Enter the 1st best score: ";
  22.         cin >> record[c].bestScore1;
  23.         cout << "Enter the 2nd best score: ";
  24.         cin >> record[c].bestScore2;
  25.         system("cls");
  26.     }  
  27. }
  28.  
  29. void ViewRecord() {
  30.     PlayerRecord player;
  31.     cout << "Nickname \t\t Age \t\t Best 1 \t\t Best 2 \t" << endl;
  32.     for (int i = 0; i < 5; i++) {
  33.         cout << record[i].Nickname << "\t\t" << record[i].age << "\t\t" << record[i].bestScore1 << "\t\t\t" << record[i].bestScore2 << endl;
  34.     }
  35.     system("pause");
  36. }
  37.  
  38. void GetAverage() {
  39.     PlayerRecord player;
  40.     float average;
  41.     cout.setf(ios::fixed);
  42.     cout.setf(ios::showpoint);
  43.     cout.precision(2);
  44.     cout << "Nickname \t\t Best 1 \t\t Best 2 \t\t Average" << endl;
  45.     for (int v = 0; v < 5; v++) {
  46.         average = (record[v].bestScore1 + record[v].bestScore2)/2;
  47.         cout << record[v].Nickname << "\t\t" << record[v].bestScore1 << "\t\t\t" << record[v].bestScore2 <<"\t\t\t" << average << endl;            
  48.     }
  49.     system("pause");
  50. }
  51.  
  52. void GetMax() {
  53.    
  54. }
  55.  
  56.  
  57. void MainMenu() {
  58.     PlayerRecord player;
  59.     int choice;
  60.     cout << "==============================" << endl;
  61.     cout << "|             MENU           |" << endl;
  62.     cout << "==============================" << endl;
  63.     cout << "1. Add record" << endl;
  64.     cout << "2. View player records" << endl;
  65.     cout << "3. Compute for average" << endl;
  66.     cout << "4. Show the player(s) who gets the max average" << endl;
  67.     cout << "5. Show the player(s) who gets the min average" << endl;
  68.     cout << "6. Exit" << endl;
  69.     cout << "Enter your choice: ";
  70.     cin >> choice;
  71.     switch (choice) {
  72.         case 1:
  73.             AddRecord();
  74.             system("cls");
  75.             MainMenu();
  76.             break;
  77.         case 2:
  78.             ViewRecord();
  79.             system("cls");
  80.             MainMenu();
  81.             break;
  82.         case 3:
  83.             GetAverage();
  84.             system("cls");
  85.             MainMenu();
  86.             break;
  87.         case 6:
  88.             system("exit");
  89.     }
  90. }
  91.  
  92. int main() {
  93.     MainMenu();
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement