Can anyone check my c++ code please.....

This is my code :-

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <iostream>
using namespace 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;

	else if (airfareAmountin == 2)
		airfareAmount = 1100;

	else if (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 .
Last edited on
1
2
3
4
5
6
7
int airfareAmount()
{
int airfareAmount; // to be returned to user once calculated
int airfareAmountin; // For input from user
// all your calculations...

return airfareAmount;}


Used in main like this:

int airfareAmount = airfareAmount();
Last edited on
Topic archived. No new replies allowed.