Java program for banking ticket system using if-else statement

Java program for banking ticket system using if-else statement. Each customer receives a ticket and is served when their number is called in a bank’s ticketing system. Consider the following scenario: five consumers each take a ticket from our ticketing system. The first customer has a ticket with the number 3 on it, while the fifth has a ticket with the number 10.Customers who purchase tickets should form a line, with the customer with the first ticket being served first. When the first customer has been served, the ticket in question is withdrawn from the line.

import java.util.*;
public class Main
{
public static void main (String[] args)
{
Scanner sc=new Scanner(System.in);

System.out.println("Enter the number of the customer");
int n=sc.nextInt();
if(n>0)
{
int[] Main=new int[n];

System.out.println("The ticket in the system is");
for(int i=0;i<n;i++)
{
Main[i]=i+1;
System.out.print(Main[i]+" ");
}
System.out.println();
System.out.println("Enter the number of ticket distributed ");
int served=sc.nextInt();

if(served>0 && served<=n)
{
System.out.println("The distributed tickets are");
for(int i=0;i<served;i++)
{
System.out.print(Main[i]+" ");
}
System.out.println();

if(served!=n)
{
System.out.println("The undistributed tickets are:");
for(int i=served;i<n;i++)
{
System.out.print(Main[i]+" ");
}
}
else
{
System.out.println("No more mains to be served");
}
}

}
else
{
System.out.println("Invalid Number");
}

}
}

 

Output:

Enter the number of the customer
4
The ticket in the system is
1 2 3 4
Enter the number of ticket distributed
3
The distributed tickets are
1 2 3
The undistributed tickets are:
4