Final C++ Project
Final C++ Project
Under supervision:
Prof Dr. Mohamed Faisel
By:
1-Andrew Eskander Zarif
2-Mohamed Baleegh Hosny
3-Omar Mohammed Saidan
4-Omar Ahmed Sayed Ali
1
Airline Calculations C++ program project
1. Abstract
This program calculates baggage costs for airline passengers based on ticket
type, handling excess weight, dimensions, and number of bags. The report covers
its purpose, implementation, user interactions, and example inputs/outputs, with
predefined passenger details for demonstration.
2. Purpose of the
Program
This program automates
excess baggage fee
calculations, ensuring
efficiency, user-friendliness,
and accuracy. It supports the
following ticket types:
• Economy
• Business
• Economy Star
Membership
• Business Star
Membership
• Business Normal
Membership
2
Airline Calculations C++ program project
3. Coding overview:
The code manages the interaction with the user, starting with passenger identification
based on SSN. It then processes details about checked baggage and hand luggage,
validates their dimensions and weight, calculates additional costs for excess limits
and finally displays the total cost in a clear format and that we will discuss the
following topic:-
3
Airline Calculations C++ program project
Explanation of the Functions: -
1. Passenger Class
➢ Purpose: Manages passenger details such as name, nationality, age, SSN, and passenger type.
❖ Key Elements:
o Private Attributes:
• name: Stores the passenger's name.
• nationality: Stores the passenger's nationality.
• passengerType: Indicates the type of passenger (e.g., Economy, Business).
• age: Stores the passenger's age.
• ssn: Stores the passenger's Social Security Number.
o Getter Methods:
• getSSN(): Returns the passenger’s SSN.
• getPT(): Returns the passenger’s type.
o displayDetails() Method:
• Outputs all passenger details to the console in a structured format.
4
Airline Calculations C++ program project
5
Airline Calculations C++ program project
2. cost_of_baggageweight()
➢ Purpose: Calculates the cost of extra baggage weight based on the passenger’s class.
➢ Logic:
❖ For Business Class (and variations):
• Maximum allowed weight: 32 kg.
• For every kg exceeding 32, a fee of 50 EGP is applied.
❖ For Economy Class (and variations):
• Maximum allowed weight: 23 kg.
• For every kg exceeding 23, a fee of 50 EGP is applied.
❖ Displays the baggage weight and applicable fees.
➢ Returns: The total fee for the extra baggage weight
6
Airline Calculations C++ program project
3. cost_of_handluggageweight()
➢ Purpose: Calculates the cost of extra hand luggage weight based on the passenger’s class.
➢ Logic:
➢ Returns: The total fee for the extra hand luggage weight.
7
Airline Calculations C++ program project
4. num_of_baggageCalc()
➢ Logic:
8
Airline Calculations C++ program project
5. num_of_handLagguageCalc()
➢ Logic:
9
Airline Calculations C++ program project
6. drawRectangleAroundText()
➢ Purpose: Visually formats two lines of text within a rectangle for clear and aesthetically
pleasing output.
➢ Logic:
• Determines the maximum line length from the two input strings.
• Creates a rectangle with padding around the text, including top and bottom borders, left
and right padding, and alignment for the shorter line.
• Outputs the formatted rectangle to the console.
10
Airline Calculations C++ program project
Explanation of int main (): -
1. Passenger Lookup:
2. Baggage Handling:
• Asks the user if they have checked baggage.
• If yes, prompts the user to enter the number of bags (0 to 4).
• For each bag, the dimensions and weight are entered and validated against predefined limits.
• Additional costs are calculated for excess weight or oversize baggage using helper functions
like cost_of_baggageweight() and num_of_baggageCalc().
11
Airline Calculations C++ program project
12
Airline Calculations C++ program project
3. Hand Luggage Handling:
• Like baggage handling, it asks if the user has hand luggage.
• If yes, the user enters the number of hand luggage items (0 to 4).
• For each hand luggage item, dimensions and weight are validated.
• Additional costs are calculated for exceeding the weight or size limits using appropriate
helper functions.
13
Airline Calculations C++ program project
14
Airline Calculations C++ program project
Case 1: - Passenger Details: -
The passenger "Mohammed Baleegh" has a • SSN: 102030405
(Business star membership) ticket allowing • Name: Mohammed Baleegh
him to carry 2 bags, each weighing up to 23 • Age: 20
kg, with extra charges for additional bags • Nationality: Egyptian
and weight. • Passenger Type: STAR MEMBERSHIP
Business
15
Airline Calculations C++ program project
Weight: Mohamed Baleegh (Business Star) is allowed
2 handbags, each up to 8 kg and 118 cm in
The bag weight must be between 0 and dimensions. Extra bags cost 1,000 LE, and
50 kg. If within the allowed range, the extra weight costs 50 LE/kg.
program will proceed.
Allowed: 2 bags (max 32 kg), extra bag: -Handbag 1: 110 cm, 14 kg → Extra
1,000 LE, extra weight: 50 LE/kg weight 6 kg → 6 * 50 = 300 LE
16
Airline Calculations C++ program project
17
Airline Calculations C++ program project
Case 2: - Passenger Details: -
The passenger "Omar Toleba" has an • SSN: 506078009
(Economy star membership) ticket • Name: Omar Toleba
allowing him to carry 2 bags, each • Age: 20
weighing up to 23 kg, with extra charges • Nationality: Egyptian
for additional bags and weight. • Passenger Type: STAR MEMBERSHIP
Economy
18
Airline Calculations C++ program project
Handbag Details: - Total Extra Charges: -
19
Airline Calculations C++ program project
20
Airline Calculations C++ program project
Case 3: - Passenger Details: -
Omar Mohamed, with a business • SSN: 123456789
• Name: Omar Mohammed
ticket, is allowed 1 bag (up to 32 • Age: 21
kg) and 2 handbags (up to 8 kg • Nationality: German
each). He is within the allowed • Passenger Type: Business
limits and will not incur any extra
charges.
21
Airline Calculations C++ program project
22
Airline Calculations C++ program project
Case 4: - Passenger Details: -
Bags:
Handbags:
Total charges:
350 LE (bags) + 1200 LE (handbags) =
1550 LE.
23
Airline Calculations C++ program project
24
Airline Calculations C++ program project
Case 5: - Passenger Details: -
• SSN: 123789456
For the passenger "Ahmed Ali", who holds a
• Name: Ahmed Ali
Normal Business membership ticket, he is
• Age: 42
allowed:
• Nationality: Egyptian
• 2 Bags (up to 32 kg), and since he has 2
• Passenger Type: Normal Business
bags, there are no extra charges for the
membership
number of bags.
• No Handbags, so there are no extra
charges for handbags.
Bags:
Handbags:
• No Handbags
• Total charge for
Handbags:0LE
Total charges:
50 LE (bags) + 0 LE (handbags) = 50
LE.
25
Airline Calculations C++ program project
26
Airline Calculations C++ program project
4. Conclusion: -
27
Airline Calculations C++ program project