What's new

Help Program/Code MRT Fare Matrix

Rastafries420

Eternal Poster
Joined
Jul 20, 2022
Posts
700
Reaction
240
Points
394
Newbie sa paging IT student, bale may pinapagawa sa amin/project ni Prof about parang gagawa daw kami ng Code/Program about sa MRT Fare Matrix (Ticketing) using C++....diko masyado gets yun kasi apaka bilis mag salita ni sir basta Yung pinapagawa is dapat pag gusto daw nya pumunta sa iba't ibang destinations lalabas daw Yung fare, basta ganon hshshhshhs....pa help mga Phc Masters tytyyt
images (5).jpeg
 

Attachments

Hello! I can definitely help you with your MRT Fare Matrix project in C++. Don't worry, I will break down the requirements for you so it's easier to understand.

First, you need to create a program that will calculate and display the fare for different destinations in the MRT system. To do this, you will need to have a matrix (or a 2-dimensional array) that represents the different stations and their corresponding fares.

Here's an example of how you can represent the MRT stations and their fares using a 2D array in C++:

C++:
#include <iostream>
using namespace std;

int main() {
    string stations[] = { "Station A", "Station B", "Station C", "Station D", "Station E" };
    int fares[][5] = {
        { 0, 10, 20, 30, 40 },
        { 10, 0, 10, 20, 30 },
        { 20, 10, 0, 10, 20 },
        { 30, 20, 10, 0, 10 },
        { 40, 30, 20, 10, 0 }
    };

    // Display the fare matrix
    cout << "MRT Fare Matrix:" << endl;
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {
            cout << fares[i][j] << "\t";
        }
        cout << endl;
    }

    // Get user input for source and destination stations
    int source, destination;
    cout << "Enter source station (0-4): ";
    cin >> source;
    cout << "Enter destination station (0-4): ";
    cin >> destination;

    // Calculate and display the fare
    int fare = fares[source][destination];
    cout << "Fare from " << stations[source] << " to " << stations[destination] << ": " << fare << endl;

    return 0;
}

In this example, the stations array stores the names of the MRT stations, and the fares 2D array stores the fare values between each pair of stations. The fare from station A to station B can be accessed using fares[0][1].

The code prompts the user to enter the source and destination stations (using the index number of the stations), calculates the fare by accessing the corresponding fare value from the fares array, and then displays the fare.

Feel free to modify the code to fit your specific requirements and expand it as needed. Good luck with your project!
 

Similar threads

Back
Top