#include <iostream>
usingnamespace std;
int totalDays();
int departureTime();
int arrivalTime();
void airfareAmount(int& airfareAmountin);
double carRental;
double privateVehicle;
double privateVehicleexpense;
double parkingFee;
double taxiFee;
double conf_regFee;
double hotelAmount;
double totalExpense;
double totalAllowexpense;
int main()
{
int X = 5;
totalDays();
departureTime();
arrivalTime();
airfareAmount(X);
cout << X << endl;
return 0;
}
int totalDays()
{
int totalDaysin;
cout << "The total range number of days spent on trip\n" << endl;
cout << "\t1) 1 - 3 Days" << endl;
cout << "\t2) 4 - 7 Days" << endl;
cout << "\t3) 8 - 10 Days" << endl;
cout << "\nInput value : ";
cin >> totalDaysin;
return 0;
}
int departureTime()
{
int departureTimein;
do
{
cout << "\nEnter the departure time on the first day of the trip in hours : ";
cin >> departureTimein;
if (departureTimein > 23)
cout << "\nYou have entered an invalid value . Please enter value from 00 - 23.\n ";
}
while (departureTimein > 23);
return 0;
}
int arrivalTime()
{
int arrivalTimein;
do
{
cout << "\nEnter the arrival time on the last day of the trip in minutes : ";
cin >> arrivalTimein;
if (arrivalTimein > 59)
cout << "\nYou have entered an invalid value . Please enter value from 00 - 23.\n ";
}
while (arrivalTimein > 59);
return 0;
}
void airfareAmount(int& airfareAmountin)
{
int airfareAmount;
cout << "\n\nThe total amount of round-trip airfare\n" << endl;
cout << "\t1) First Class : RM 1500" << endl;
cout << "\t2) Business Class : RM 1100" << endl;
cout << "\t3) Economy Class : RM 800" << endl;
cout << "\nInput value : ";
cin >> airfareAmountin;
if (airfareAmountin == 1)
airfareAmount = 1500;
elseif (airfareAmountin == 2)
airfareAmount = 1100;
elseif (airfareAmountin == 3)
airfareAmount = 800;
}
My question is : -
I wanted to pass the value of airfareAmount from airfareAmount function call which selected to main function of "X" . But , the output of "X" in main function still shows the values of airfareAmountin . For example , I want the value of "X" in main function appear as 1100 if I input the value of 2 for airfareAmount function call . Thanks in advanced .
int airfareAmount()
{
int airfareAmount; // to be returned to user once calculated
int airfareAmountin; // For input from user
// all your calculations...
return airfareAmount;}