Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is for a c++ program. I have no idea where to even begin with it. Any help

ID: 3570317 • Letter: T

Question

This is for a c++ program. I have no idea where to even begin with it. Any help is appreciated.

Objectives
To gain more experience with Classes, Friend functions and Overloading Operators.

Problem
For this project you should design and implement an online tourism application for a travel agent
who wants his customers to enquire and book for a tourism package using the application.
Assumptions

1) Our agent has only four destinations for which he can offer services.
2) All the details about the four destinations are provided in the input file
3) The maximum number of passengers the agent can accommodate is 20.
4) Initial price quote available in the file is for 1 person and it does not include accomodation.
5) Every Customer must choose one of the three accommodation options available.

Description:
1) You need to create a class called TravelInfo which has the following members
? DestinationName(String)
? TravelDays(int)
? TripCost(double)
Note : All the above attributes should only be accessible through methods of the TravelInfo class.
? void add_travelDays(int days);
This function should add any additional days that the user wants to add to his tour package
and update the members TravelDays and TripCost accordingly.
? void add_hotel();
This function asks the user for the type of hotel he wishes to stay in and updates the TripCost
based on TravelDays. Our agent offers three different categories of hotels. 1) Economy
($70/day) 2)Luxury ($180$/day) and 3) Elite ($320/day)
? void rent_a_car( int rentDays);
This function asks the user to add any rental car to his package and updates the TripCost
based on rentDays. Our Agent offers a rental car for a cost of $40/day to his customers.
? friend void CompareTrip(const TravelInfo& tour1 , const TravelInfo& tour2);
This is friend function which takes the TravelInfo Objects, compares the TripCost of two
objects and tells the user about the cheapest destination.
You must write two constructors for the TravelInfo class
? A default constructor
? An overloaded constructor that takes in three parameters and sets the DestinationName,
TravelDays, and TripCost.
You must write one set method (mutator) and get method (accessor) for each of the attributes of the
TravelInfo class.
After you have defined all the members, overload the following operator:
<< - to output all the details of the existing TravelInfo object.
2) You need to create a structure called PassengerDetails with the following members
? PassengerName(string)
? Destination(String)
? Gender(char)
3) Declare a function outside structure:
bool checkAvailablity(int size,int NumOfPassengers, int MAX_SIZE);
This function returns true if the sum of size and NumOfPassengers is less than the MAX_SIZE

Implementation

In the main Program-
1) Create four different objects for the TravelInfo class and read the input file to fill in all the details
of the created objects.
2) Create an array of PassengerDetails objects with a capacity of MAX_SIZE of 20 and a size
variable to keep track of actual elements of the array used
3) Display a menu for the Following options for the user-
? To view all the available tour packages
Display the information of all the available tour packages using the overloaded <<
? To compare two different tour packages
Take the input of two different destinations, and call the friend function CompareTrip() with
appropriate objects as arguments
? Proceed to booking for an available package
a) Ask the user to choose a package based on destination.
b) Add any additional travel days.
c) Give the option to choose the accommodation type. c) Ask the user to choose for the additional features like renting a car.
d) Then ask the user for the number of passengers as input from keyboard and call the
checkAvailablity() function with appropriate arguments .
e) If the function returns true, then read the input for all of the details of the passenger from the
keyboard.
f) Then display the details of all passengers entered by the user on screen for the customer
reference.
g) Finally display total trip cost.
h) If the function returns false, ask the user if he would like to choose a different tour
package.
? Exit
Terminate the program

Remember to repeat the menu of choices for the user.

Explanation / Answer

#include <iostream>
#include <fstream>
#include <string>
#include <sstream>

using namespace std;

class TravelInfo{
private:
   string DestinationName;
   int TravelDays;
   double TripCost;
public:
   TravelInfo();
   TravelInfo(string dn, int td, double tc);
   void setDestinationName(string Destination){
       DestinationName = Destination;
   }

   string getDestinationName(){
       return DestinationName;
   }

   void setTravelDays(int Days){
       TravelDays = Days;
   }

   int getTravelDays(){
       return TravelDays;
   }

   void setTripCost(double Cost){
       TripCost = Cost;
   }

   double getTripCost(){
       return TripCost;
   }
   void add_travelDays(int days);
   void add_hotel();
   void rent_a_car(int rentDays);
   friend void compareTrip(const TravelInfo& tour1, const TravelInfo& tour2);
   friend void operator << (ostream &out, const TravelInfo &tour);
};

TravelInfo::TravelInfo(){
   DestinationName = "";
   TravelDays = 0;
   TripCost = 0;
}

TravelInfo::TravelInfo(string dn, int td, double tc){
   DestinationName = dn;
   TravelDays = td;
   TripCost = tc;
}

void TravelInfo::add_travelDays(int days){
   TravelDays += days;
   TripCost += (days*((TripCost) / (TravelDays)));
}

void TravelInfo::add_hotel(){
   cout << "Our agent offers three different categories of hotels. " << endl;
   cout << "1) Economy($70 / day) " << endl;
   cout << "2) Luxury($180$ / day) " << endl;
   cout << "3) Elite($320 / day)" << endl;
   int choice;
   while (true){
       cout << "Choose an option:(1 or 2 or 3) ";
       cin >> choice;
       switch (choice){
       case 1:
           TripCost += (TravelDays * 70);
           return;
       case 2:
           TripCost += (TravelDays * 180);
           return;
       case 3:
           TripCost += (TravelDays * 320);
           return;
       default:
           cout << "Enter a valid choice" << endl;
       }
   }
}

void TravelInfo::rent_a_car(int rentDays){
   TripCost += (rentDays * 40);
}


void compareTrip(const TravelInfo& tour1, const TravelInfo& tour2){
   if (tour1.TripCost > tour2.TripCost){
       cout << "The second tour is costlier." << endl;
   }
   else if (tour1.TripCost < tour2.TripCost){
       cout << "The first tour is costlier." << endl;
   }
   else{
       cout << "They both cost the same.";
   }
}

void operator << (ostream &out, const TravelInfo& ob){
   out << "TripCost = " << ob.TripCost << endl << "TravelDays = " << ob.TravelDays << endl;
   cout << "DestinationName = " << ob.DestinationName << endl;
}

struct PassengerDetails{
   string PassengerName;
   string Destination;
   char Gender;
};

bool checkAvailablity(int size, int NumOfPassengers, int MAX_SIZE){
   if (size + NumOfPassengers < MAX_SIZE){
       return true;
   }
   return false;
}

int main(){
   ifstream in_file;
   in_file.open("FileNameXYZ.txt");
   int i = 1, j = 0;
   TravelInfo ob[4];
   string val;
   if (in_file.is_open()){
       while (in_file >> val){
           if ((i % 3) == 1){
               ob[j].setDestinationName(val);
           }
           else if ((i % 3) == 2){
               int days;
               stringstream ss;
               ss << val;
               ss >> days;
               ob[j].setTravelDays(days);
           }
           else if ((i % 3) == 0){
               double cost;
               stringstream ss;
               ss << val;
               ss >> cost;
               ob[j].setTripCost(cost);
               ++j;
           }
           ++i;
       }
   }
   else{
       cout << "Cannot open the file" << endl;
       exit(1);
   }
   PassengerDetails passengers[20];
   int size = 0;
   int option;
   int ind1 = -1, ind2 = -1;
   string name1, name2;
   cout << "Enter 1 To view all the available tour packages" << endl;
   cout << "Enter 2 To compare two different tour packages" << endl;
   cout << "Enter 3 To Proceed to booking for an available package" << endl;
   do{
       cout << "Enter Your option: ";
       cin >> option;
       switch (option){
       case 1:
           for (int i = 0; i < 4; ++i){
               cout << ob[i];
           }
           break;
       case 2:
           cout << "Enter destination 1?" << endl;
           cin >> name1;
           for (int i = 0; i < 4; ++i){
               if (ob[i].getDestinationName() == name1){
                   ind1 = i;
                   break;
               }
           }
           if (ind1 == -1){
               cout << "Invalid Destination Name" << endl;
               break;
           }
           cout << "Enter destination 2?" << endl;
           cin >> name2;
           for (int i = 0; i < 4; ++i){
               if (ob[i].getDestinationName() == name2){
                   ind2 = i;
                   break;
               }
           }
           if (ind2 == -1){
               cout << "Invalid Destination Name" << endl;
               break;
           }
           compareTrip(ob[ind1], ob[ind2]);
           break;
       case 3:
           break;
       default:
           cout << "Enter a valid option" << endl;
       }
   } while (option != 3);

   // second menu

   while(true) {
       cout << "Choose a Package" << endl;
       int ind = -1;
       do{
           cout << "Destination Name: ";
           string name;
           cin >> name;
           for (int i = 0; i < 4; ++i){
               if (ob[i].getDestinationName() == name){
                   ind = i;
                   break;
               }
           }
           if (ind == -1){
               cout << "Enter Valid Destination Name: ";
           }
       } while (ind == -1);
       cout << endl << endl << "Do you need Additional Travel Days(yes or no)" << endl;
       string yorn;
       cin >> yorn;
       if (yorn == "yes" || yorn == "YES"){
           cout << "Number of additional days needed: ";
           int adddays;
           cin >> adddays;
           ob[ind].add_travelDays(adddays);
       }
       cout << endl << endl << "choose the accommodation type" << endl;
       cout << "Enter 1 for Hotel" << endl;
       cout << "Enter 2 for renting a car" << endl;
       cout << "Enter 3 to exit" << endl;
       int cardays;
       do{
           cout << "Choose your option" << endl;
           cin >> option;
           switch (option){
           case 1:
               ob[ind].add_hotel();
               break;
           case 2:
               cout << "Enter Number of days you want to rent a car: ";
               cin >> cardays;
               ob[ind].rent_a_car(cardays);
               break;
           case 3:
               break;
           default:
               cout << "Enter a valid option" << endl;
               break;
           }
       } while (option != 3);
       cout << endl << "Number of passengers: ";
       int numpass;
       cin >> numpass;
       if (checkAvailablity(size, numpass, 20)){
           cout << "Enter details of all passengers" << endl;
           int sind = size;
           for (int i = 0; i < numpass; ++i){
               cout << "Passenger " << i + 1 << ": " << endl;
               cout << "Name: ";
               string name;
               passengers[size].PassengerName = name;
               cout << "Gender: ";
               char gen;
               cin >> gen;
               passengers[size].Gender = gen;
               size++;
           }
           for (int i = sind; i < sind + numpass; ++i){
               cout << "Name: " << passengers[i].PassengerName << endl;
               cout << "Gender: " << passengers[i].Gender << endl << endl;
           }
           cout << "Total Trip cost is " << ob[ind].getTripCost() << endl;
           break;
       }
       else{
           cout << "Not available!" << endl;
           cout << "Do you want to choose another tour (yes or no) : ";
           cin >> yorn;
           if (yorn != "yes" && yorn != "YES"){
               break;
           }
           else{
               cout << endl << "New Tour Begins!" << endl << endl;
           }
       }
   }

   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote