In the previous lab, we used loops to accept passenger details one by one.
The Problem:
Imagine a family of five books a flight. If we store each passenger's name and age in separate variables, the program quickly becomes difficult to manage.
The Solution : Use Arrays
Your next task is to organize passenger details using arrays, making the booking system more efficient and organized.
Pre-Lab Preparation
git pull origin branchName
Git Pull
Task 1: Creating new class For FlightBookings
1
Declare the required variables and array. Make sure that the Scanner object is declared so as to accept user input
Topic :
1) Understanding of 1D arrays
2) Understanding of for loop
2
Accept the passenger names and store them in String array
3
Display the array contents
4
Run the code to check the output
5
Declare the byte array to store the age
6
Display the passenger name, with respective age
7
Run the code to check the output
Great job! You have successfully used loops to process multiple passenger records efficiently. Your SkyReserve booking system can now handle repeated user inputs with ease.