0% found this document useful (0 votes)
14 views6 pages

C++ Travels Management System

The document presents a C++ program for a Travels Management System that allows users to manage travel reservations. It includes classes for Travels, Route, and Reservation, enabling the acceptance and display of travel details, routes, and reservations. The program also allows users to search for reservations based on a specific travel date.

Uploaded by

p9280840
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views6 pages

C++ Travels Management System

The document presents a C++ program for a Travels Management System that allows users to manage travel reservations. It includes classes for Travels, Route, and Reservation, enabling the acceptance and display of travel details, routes, and reservations. The program also allows users to search for reservations based on a specific travel date.

Uploaded by

p9280840
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

C++ Program: Travels Management System

C++ Program Code:


#include <iostream>

#include <vector>

using namespace std;

class Travels {

protected:

int T_no;

string company_name;

public:

void acceptTravels() {

cout << "Enter Travel Number: ";

cin >> T_no;

cout << "Enter Company Name: ";

cin.ignore();

getline(cin, company_name);

void displayTravels() {

cout << "Travel No: " << T_no << ", Company: " << company_name << endl;

};

class Route : public Travels {

protected:

int route_id;

string source, destination;

public:

void acceptRoute() {
acceptTravels();

cout << "Enter Route ID: ";

cin >> route_id;

cout << "Enter Source: ";

cin.ignore();

getline(cin, source);

cout << "Enter Destination: ";

getline(cin, destination);

void displayRoute() {

displayTravels();

cout << "Route ID: " << route_id << ", From: " << source << " To: " <<

destination << endl;

};

class Reservation : public Route {

private:

int num_seats;

string travel_class, travel_date;

float fare;

public:

void acceptReservation() {

acceptRoute();

cout << "Enter Number of Seats: ";

cin >> num_seats;

cout << "Enter Travel Class (Economy/Business): ";

cin >> travel_class;

cout << "Enter Fare: ";

cin >> fare;

cout << "Enter Travel Date (DD-MM-YYYY): ";


cin >> travel_date;

void displayReservation() {

displayRoute();

cout << "Seats: " << num_seats << ", Class: " << travel_class

<< ", Fare: " << fare << ", Date: " << travel_date << endl;

string getTravelDate() {

return travel_date;

};

int main() {

vector<Reservation> reservations;

int n;

cout << "Enter number of reservations: ";

cin >> n;

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

cout << "\nEnter details for reservation " << i + 1 << ":

";

Reservation res;

res.acceptReservation();

reservations.push_back(res);

cout << "\nAll Reservations:

";

for (auto &res : reservations) {

res.displayReservation();
cout << "---------------------------------

";

string search_date;

cout << "\nEnter date (DD-MM-YYYY) to search reservations: ";

cin >> search_date;

cout << "\nReservations on " << search_date << ":

";

bool found = false;

for (auto &res : reservations) {

if (res.getTravelDate() == search_date) {

res.displayReservation();

cout << "---------------------------------

";

found = true;

if (!found) {

cout << "No reservations found for this date.

";

return 0;

Example Output:
Example Output:

Enter number of reservations: 2

Enter details for reservation 1:


Enter Travel Number: 101

Enter Company Name: RedBus

Enter Route ID: 501

Enter Source: Mumbai

Enter Destination: Pune

Enter Number of Seats: 3

Enter Travel Class (Economy/Business): Economy

Enter Fare: 500

Enter Travel Date (DD-MM-YYYY): 25-02-2025

Enter details for reservation 2:

Enter Travel Number: 102

Enter Company Name: VRL Travels

Enter Route ID: 601

Enter Source: Delhi

Enter Destination: Jaipur

Enter Number of Seats: 2

Enter Travel Class (Economy/Business): Business

Enter Fare: 1200

Enter Travel Date (DD-MM-YYYY): 26-02-2025

All Reservations:

Travel No: 101, Company: RedBus

Route ID: 501, From: Mumbai To: Pune

Seats: 3, Class: Economy, Fare: 500, Date: 25-02-2025

---------------------------------

Travel No: 102, Company: VRL Travels

Route ID: 601, From: Delhi To: Jaipur

Seats: 2, Class: Business, Fare: 1200, Date: 26-02-2025

---------------------------------

Enter date (DD-MM-YYYY) to search reservations: 25-02-2025


Reservations on 25-02-2025:

Travel No: 101, Company: RedBus

Route ID: 501, From: Mumbai To: Pune

Seats: 3, Class: Economy, Fare: 500, Date: 25-02-2025

---------------------------------

You might also like