Managing Passenger Manifest using Arrays

Business Scenario

Welcome back,Developers!

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.

Checkpoint

Next-Lab Preparation

Topic :

1) Understanding of arrays (especially 2D arrays)

2) Understanding of for loop

3) Understanding of row and column indexing

   Git Push

git push origin branchName

Java - lab 7

By Content ITV

Java - lab 7

  • 14