Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct PlayerRecord{
- char Nickname [50];
- int age;
- float bestScore1;
- float bestScore2;
- float average;
- }record[5];
- void AddRecord() {
- PlayerRecord player;
- system("cls");
- for (int c = 0; c < 5; c++) {
- cout << "Player " << c+1 << endl;
- cout << "Enter the nickname: ";
- cin >> record[c].Nickname;
- cout << "Enter the age: ";
- cin >> record[c].age;
- cout << "Enter the 1st best score: ";
- cin >> record[c].bestScore1;
- cout << "Enter the 2nd best score: ";
- cin >> record[c].bestScore2;
- system("cls");
- }
- }
- void ViewRecord() {
- PlayerRecord player;
- cout << "Nickname \t\t Age \t\t Best 1 \t\t Best 2 \t" << endl;
- for (int i = 0; i < 5; i++) {
- cout << record[i].Nickname << "\t\t" << record[i].age << "\t\t" << record[i].bestScore1 << "\t\t\t" << record[i].bestScore2 << endl;
- }
- system("pause");
- }
- void GetAverage() {
- PlayerRecord player;
- float average;
- cout.setf(ios::fixed);
- cout.setf(ios::showpoint);
- cout.precision(2);
- cout << "Nickname \t\t Best 1 \t\t Best 2 \t\t Average" << endl;
- for (int v = 0; v < 5; v++) {
- average = (record[v].bestScore1 + record[v].bestScore2)/2;
- cout << record[v].Nickname << "\t\t" << record[v].bestScore1 << "\t\t\t" << record[v].bestScore2 <<"\t\t\t" << average << endl;
- }
- system("pause");
- }
- void GetMax() {
- }
- void MainMenu() {
- PlayerRecord player;
- int choice;
- cout << "==============================" << endl;
- cout << "| MENU |" << endl;
- cout << "==============================" << endl;
- cout << "1. Add record" << endl;
- cout << "2. View player records" << endl;
- cout << "3. Compute for average" << endl;
- cout << "4. Show the player(s) who gets the max average" << endl;
- cout << "5. Show the player(s) who gets the min average" << endl;
- cout << "6. Exit" << endl;
- cout << "Enter your choice: ";
- cin >> choice;
- switch (choice) {
- case 1:
- AddRecord();
- system("cls");
- MainMenu();
- break;
- case 2:
- ViewRecord();
- system("cls");
- MainMenu();
- break;
- case 3:
- GetAverage();
- system("cls");
- MainMenu();
- break;
- case 6:
- system("exit");
- }
- }
- int main() {
- MainMenu();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement