0% found this document useful (0 votes)
4 views1 page

Main

This Java program collects information about passengers, including ticket ID, name, gender, and address. It prompts the user to enter the number of passengers and stores their details in an array of Passenger objects. Finally, it prints out the details of each passenger entered.

Uploaded by

prasannamkp10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Main

This Java program collects information about passengers, including ticket ID, name, gender, and address. It prompts the user to enter the number of passengers and stores their details in an array of Passenger objects. Finally, it prints out the details of each passenger entered.

Uploaded by

prasannamkp10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.util.

Scanner;
public class Main{
public static void main(String args[]){
Scanner s=new Scanner(System.in);
System.out.println("Enter the no of passengers:");
int n=s.nextInt();
Passenger arr[]=new Passenger [n];
for( int i=0;i<n;i++)
{
System.out.println("Passenger "+(i+1));
System.out.println("Enter the ticketid:");
int b=s.nextInt();
System.out.println("Enter the name:");
s.nextLine();
String c=s.nextLine();
System.out.println("Enter the gender:");
//s.nextLine();
String d=s.nextLine();
System.out.println("Enter the address:");
String e=s.nextLine();
arr[i]=new Passenger(b,c,d,e);
}

for(int i=0;i<n;i++)
System.out.println(arr[i]);
}
}

You might also like