Untitled

 avatar
unknown
c_cpp
a year ago
2.8 kB
4
Indexable
#include <iostream>
#include <string.h>

using namespace std;

void DisplayStadium(char stadiumName[]);

int main()
{
    char stadiumName[60]; // Assuming a reasonable maximum length for stadiumName
    DisplayStadium(stadiumName);
    cout << "You have chosen " << stadiumName << " to watch a sports match." << endl;
}

void DisplayStadium(char stadiumName[])
{
    int chooseStadium;
    cout << "==========================================================================================="<<endl;
    cout << "||               NUMBER                ||               STADIUM                          ||"<<endl;
    cout << "==========================================================================================="<<endl;
    cout << "==========================================================================================="<<endl;
    cout << "||                 1                   ||   BUKIT JALIL NASIONAL STADIUM, KUALA LUMPUR   ||"<<endl;
    cout << "==========================================================================================="<<endl;
    cout << "||                 2                   ||          MERDEKA STADIUM, KUALA LUMPUR         ||"<<endl;
    cout << "==========================================================================================="<<endl;
    cout << "||                 3                   ||          SHAH ALAM STADIUM, SHAH ALAM          ||"<<endl;
    cout << "==========================================================================================="<<endl;
    cout << "||                 4                   ||  TUANKU ABDUL RAHMAN STADIUM, NEGERI SEMBILAN  ||"<<endl;
    cout << "==========================================================================================="<<endl;
    cout << "||                 5                   || SULTAN MIZAN ZAINAL ABIDIN STADIUM, TERENGGANU ||"<<endl;
    cout << "==========================================================================================="<<endl;

    cout << "Choose the stadium that you want (Enter the correct number only) : ";
    cin >> chooseStadium;

    while (chooseStadium < 1 || chooseStadium > 5)
    {
        cout << "You've entered the wrong number. Enter the correct number.";
        cin >> chooseStadium;
    }

    if (chooseStadium >= 1 && chooseStadium <= 5)
    {
        if (chooseStadium == 1)
            strcpy(stadiumName, "BUKIT JALIL NASIONAL STADIUM, KUALA LUMPUR");

        else if (chooseStadium == 2)
            strcpy(stadiumName, "MERDEKA STADIUM, KUALA LUMPUR");

        else if (chooseStadium == 3)
            strcpy(stadiumName, "SHAH ALAM STADIUM, SHAH ALAM");

        else if (chooseStadium == 4)
            strcpy(stadiumName, "TUANKU ABDUL RAHMAN STADIUM, NEGERI SEMBILAN");

        else
            strcpy(stadiumName, "SULTAN MIZAN ZAINAL ABIDIN STADIUM, TERENGGANU");
    }
}
Editor is loading...
Leave a Comment