0% found this document useful (0 votes)
8 views27 pages

Final C++ Project

Uploaded by

The Breaker
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)
8 views27 pages

Final C++ Project

Uploaded by

The Breaker
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/ 27

Report of 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

Next, we will explain the


program in detail, covering all
possible scenarios and cases.
This will be discussed in the
following pages, where we will
go over the logic and how the
program handles different inputs
and conditions.

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:-

Workflow: 3. Handbag Handling:


1. SSN Validation:
o Ask if the user has handbags
o Prompt the user to enter their (Y/N).
SSN.
o Repeat until a valid SSN is o For each handbag:
entered. ▪ Validate dimensions (≤118
cm: Width + Length +
2. Baggage Handling: Height).
o Ask if the user has bags (Y/N). ▪ Validate weight (≤8 kg).
o For each bag: ▪ Charge 50 LE per excess
▪ Validate dimensions (≤158
kg.
cm: Width + Length +
Height). ▪ Charge 1000 LE for each
▪ Validate weight (≤23 kg for extra handbag exceeding
Economy, ≤32 kg for the class allowance.
Business). o Calculate the total handbag cost.
▪ Charge 50 LE per excess
kg.
▪ Charge 1000 LE for each 4. Cost Calculation:
extra bag exceeding the
class allowance.
o Calculate the total baggage cost. o Calculate total cost (Bags +
Handbags).
o Display a detailed summary.

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 Constructor: Allows the creation of a Passenger object with default or custom


values.

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:

❖ Applicable to All Classes:

• Maximum allowed weight: 8 kg.


• For every kg exceeding 8, a fee of 50 EGP is applied.
• Displays the hand luggage weight and applicable fees.

➢ Returns: The total fee for the extra hand luggage weight.

7
Airline Calculations C++ program project
4. num_of_baggageCalc()

➢ Purpose: Calculates the cost of carrying extra checked bags.

➢ Logic:

❖ For Premium Classes (e.g., Business Class with Membership):

• Maximum allowed number of bags: 2.


• For every bag above this limit, a fee of 1000 EGP is applied.

❖ For Regular Classes:

• Maximum allowed number of bags: 1.


• For every bag above this limit, a fee of 1000 EGP is applied.

❖ Displays the number of bags entered and applicable fees.

➢ Returns: The total fee for the extra bags.

8
Airline Calculations C++ program project
5. num_of_handLagguageCalc()

➢ Purpose: Calculates the cost of carrying extra hand luggage.

➢ Logic:

❖ For Business Class and Premium Memberships:

• Maximum allowed number of hand luggage: 2.


• For every additional hand luggage, a fee of 1000 EGP is applied.

❖ For Economy Class and Regular Memberships:

• Maximum allowed number of hand luggage: 1.


• For every additional hand luggage, a fee of 1000 EGP is applied.

❖ Displays the number of hand luggage entered and applicable fees.

➢ Returns: The total fee for the extra hand luggage.

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:

• Prompts the user to input their SSN


(Social Security Number) and
searches through a list of predefined
Passenger objects to match the SSN.

• If the SSN is valid, the passenger’s


details are displayed, and their
Passenger Type (e.g., Business or
Economy) is stored.

• The system ensures the SSN is


correct by prompting the user until a
match is found.

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

Membership: Business Star


• Allowed Bags: 2 (extra bags cost
1,000 LE each, max 4 bags)
• Weight Limit per Bag: 32 kg (50 LE
per extra kg up to 50 kg)
• Handbags: 2 (no cost unless exceeded)
Bag Dimensions:
• Dimensions (Length + Width +
Height): Must be between 50 cm and 158
cm.

Input Details for Each Bag:

1. Bag Number (1-3)


2. Dimensions (L x W x H in cm) – Must
be > 50 cm and < 158 cm
3. Weight (kg) – Max 32 kg per bag
The program will calculate any extra
charges for additional bags or weight.

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.

Passenger: Mohamed Baleegh (Business Handbag Details:


Star)

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

Bag Details: -Handbag 2: 80 cm, 8 kg → No extra


charge
1. Bag 1: 40 kg → Extra weight 8 kg
→ 8 * 50 = 400 LE
2. Bag 2: 25 kg → No extra charge Total Payment:
3. Bag 3: 32 kg → No extra charge

Total Payment: -Extra bag: 1,000 LE


-Extra weight (bags): 400 LE
• Extra bag: 1,000 LE -Extra weight (handbags): 300 LE
• Extra weight: 400 LE
• Total: 1,400 LE
-------------Total: 1,700 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

Details of the bags:


• Bag 1: 33 kg (10 kg over limit) →
Extra fee: 10 kg * 50 LE = 500 LE
• Bag 2: 20 kg (within limit) → Extra
fee: 0 LE
• Bag 3: 23 kg (within limit) → Extra
fee: 0 LE
• Bag 4: 45 kg (22 kg over limit) →
Extra fee: 22 kg * 50 LE = 1100 LE

Extra charges for bags:


• 2 extra bags (4-2) → 2 * 1000 LE =
2000 LE
• Extra weight (10 kg + 22 kg) → 500
LE + 1100 LE = 1600 LE

Total extra charges:


2000 LE (extra bags) + 1600 LE (extra
weight) = 3600 LE

18
Airline Calculations C++ program project
Handbag Details: - Total Extra Charges: -

Handbag 1: 2000 LE (extra bags) + 500 LE (extra


weight in Bag 1) + 1100 LE (extra weight
• Size: 110 cm (within limit) in Bag 4) + 1000 LE (extra handbag) + 300
• Weight: 14 kg (6 kg over limit) LE (extra weight in Handbag 1) = 4900 LE
• Extra Fee: 6 kg × 50 LE = 300 LE
• • 2 Extra Bags: 2 × 1000 LE = 2000
Handbag 2: LE
• Extra Weight (Bag 1) : 10 kg × 50
• Size: 80 cm (within limit) LE = 500 LE
• Weight: 8 kg (within limit) • Extra Weight (Bag 4) : 22 kg × 50
• Extra Fee: 0 LE LE = 1100 LE
• 1 Extra Handbag : 1 × 1000 LE =
1000 LE
Extra Charges for Handbags: • Extra Weight (Handbag 1) : 6 kg ×
50 LE = 300 LE
• 1 Extra Handbag: 1 × 1000 LE = 1000
LE
• Extra Weight (Handbag 1): 6 kg × 50 So,
LE = 300 LE
Omar Toleba incurred a total
Total Extra Charges for Handbags:
additional fee of 4,900 LE due to
• 1000 LE (extra handbag) + 300 LE exceeding both baggage and
(extra weight) = 1300 LE handbag limits.

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.

For the passenger "Omar


Mohamed," who holds a
business ticket, he is allowed:
• 1 Bag (up to 32 kg), no extra
charges as he has only 1 bag.
• The bag is 30 kg (within
the 32 kg limit), so no
extra weight charge.
• Total charges for bags: 0
LE.
• 2 Handbags (each up to 8 kg),
no extra charges as he has 2
handbags.
• Handbag 1: 8 kg (within
the allowed weight), no
extra weight charge.
• Handbag 2: 6 kg (within
the allowed weight), no
extra weight charge.
• Total charges for
handbags: 0 LE.
Total charges: 0 LE (No extra
charges for bags or handbags).

21
Airline Calculations C++ program project
22
Airline Calculations C++ program project
Case 4: - Passenger Details: -

Andrew Eskander, with an Economy • SSN: 987654321


• Name: Andrew Eskander
ticket, is allowed 1 bag (up to 23 kg) • Age: 20
and 1 handbag (up to 8 kg). He has • Nationality: British
an extra handbag and will incur a • Passenger Type: Economy

fine of 1000 LE.

Bags:

• Bag: 30 kg (7 kg over the 23 kg


limit)
Extra weight: (30 - 23) * 50 LE
= 7 * 50 LE = 350 LE
• Total charges for bags: 350 LE

Handbags:

• Handbag 1: 8 kg (within the 8


kg limit)
No extra charge.
• Handbag 2: 12 kg (4 kg over
the 8 kg limit)
Extra weight: (12 - 8) * 50 LE
= 4 * 50 LE = 200 LE
Extra handbag fee: (2 - 1) *
1000 LE = 1000 LE
• Total charges for handbags:
200 LE (extra weight) + 1000
LE (extra handbag) = 1200 LE

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:

• 2 Bags: 30 kg (But has an extra


weight)
Extra weight: (24 - 23) * 50 LE
= 1 * 50 LE = 50 LE
• Total charges for bags: 50 LE

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: -

Passenger Name Bags Handbags Total Charges


Mohamed Baleegh 3 bags (1 extra) → 2 handbags (1 extra) → 1,700 LE
(Business Star 1,000 LE 1,000 LE
Membership) Extra weight: 8 kg on Extra weight: 6 kg on
Bag 1 → 400 LE Handbag 1 → 300 LE

Omar Toleba 4 bags (2 extra) → 2 handbags (1 extra) → 4,900 LE


(Economy Star Ticket) 2,000 LE 1,000 LE
Extra weight: 10 kg on
Bag 1 → 500 LE
Extra weight: 22 kg on
Bag 4 → 1,100 LE

Omar Mohamed 1 bag → No extra 2 handbags → No 0 LE


(Business Ticket) charges extra charges
Andrew Eskander 1 bag → No extra 2 handbags (1 extra) → 1,550 LE
(Economy Ticket) charges 1,000 LE
Extra weight: 7 kg on Extra weight: 4 kg on
Bag 1 → 350 LE Handbag 2 → 200 LE

Ahmed Ali (Normal 2 bags → No extra 0 handbags → No extra 50 LE


Business Ticket) charges charges
Extra weight: 1 kg on
Bag 1 → 50 LE

27
Airline Calculations C++ program project

You might also like