import java.io.*;
public class bro
{
public static void main(string args[])
{
seat [][]
seats=new seat[5][6];
int row, input, how many, count =0;
string name;
string movie="Movie Title:"
+"\n1:Seat"
+"\n2:view seat"
+"\n0:quit";
for (int i=0; i<5; i++)
{
seats[0]=new Seat("1");
seats[1]=new Seat("2");
seats[2]=new Seat("3");
seats[3]=new Seat("4");
seats[4]=new Seat("5");
seats[5]=new Seat("6");
}
{
System.out.println("\n"+movie);
System.out.println("Input (1-2 or 0): ");
input = Integer.parseInt(reader.next());
reader.nextLine();
switch(input)
{
case 1:
if(count == 30)
{
System.out.println("\nThe cinema is fully booked.");
}
else
{
do
{
System.out.print("How many seats would you like to book? ");
howmany = reader.nextInt();
if(howmany>5)
{
System.out.println("The maximum number of seats per booking is 5.");
}
if(howmany<1)
{
System.out.println("The minimum number of seats per booking is 1.");
}
}
while(howmany>5 // howmany<1);
for(int j=0;j<=howmany;j++)
{
printArray(seats);
do
{
System.out.println("Where would person number"+(j+1)+" like to sit?");
do
{
System.out.print("Row: ");
row=reader.nextInt();
//If the user choses a nonexistent row
if(row>5)
{
System.out.println("There are only 5 rows, please choose a new row.");
}
}
while(row>5);
do
{
System.out.print("Seat: ");
name=reader.next();
if(!name.equals("1") && !name.equals("2") && !name.equals("3") && !name.equals("4") && !name.equals("5") && !name.equals("6"))
{
System.out.println("There are only 6 seats per row, please choose a new seat.");
}
}
while(!name.equals("1") && !name.equals("2") && !name.equals("3") &&
!name.equals("4") && !name.equals("5") && !name.equals("6"));
}
while(row>5);
for(int i=0;i<6;i++)
{
if(seats[row-1].getName().equalsIgnoreCase(name))
{
if(seats[row-1].getVisible()==false)
{
System.out.println("\nThat seat is already taken, please select another one.\n");
j--;
}
{
seats[row-1].setVisible(false);
count++;
}
}
}
}
}
break;
case 2:
printArray(seats);
break;
case 0:
System.out.println("Good bye!");
break;
default:
//Informs the user that the input is not valid
System.out.println("Invalid input.");
break;
}
}
while(input != 0);
}
public static void printArray(Seat[][] a)
{
//Prints the rows
System.out.println("-SCREEN-");
for(int i=0;i<5;i++)
{
System.out.print(i+1+" ");
//Prints the seats
for(int j=0;j<6;j++)
{
System.out.print(a[j]);
}
System.out.print(" ");
System.out.println();
}
}
}
need help on this java coding...
public class bro
{
public static void main(string args[])
{
seat [][]
seats=new seat[5][6];
int row, input, how many, count =0;
string name;
string movie="Movie Title:"
+"\n1:Seat"
+"\n2:view seat"
+"\n0:quit";
for (int i=0; i<5; i++)
{
seats[0]=new Seat("1");
seats[1]=new Seat("2");
seats[2]=new Seat("3");
seats[3]=new Seat("4");
seats[4]=new Seat("5");
seats[5]=new Seat("6");
}
{
System.out.println("\n"+movie);
System.out.println("Input (1-2 or 0): ");
input = Integer.parseInt(reader.next());
reader.nextLine();
switch(input)
{
case 1:
if(count == 30)
{
System.out.println("\nThe cinema is fully booked.");
}
else
{
do
{
System.out.print("How many seats would you like to book? ");
howmany = reader.nextInt();
if(howmany>5)
{
System.out.println("The maximum number of seats per booking is 5.");
}
if(howmany<1)
{
System.out.println("The minimum number of seats per booking is 1.");
}
}
while(howmany>5 // howmany<1);
for(int j=0;j<=howmany;j++)
{
printArray(seats);
do
{
System.out.println("Where would person number"+(j+1)+" like to sit?");
do
{
System.out.print("Row: ");
row=reader.nextInt();
//If the user choses a nonexistent row
if(row>5)
{
System.out.println("There are only 5 rows, please choose a new row.");
}
}
while(row>5);
do
{
System.out.print("Seat: ");
name=reader.next();
if(!name.equals("1") && !name.equals("2") && !name.equals("3") && !name.equals("4") && !name.equals("5") && !name.equals("6"))
{
System.out.println("There are only 6 seats per row, please choose a new seat.");
}
}
while(!name.equals("1") && !name.equals("2") && !name.equals("3") &&
!name.equals("4") && !name.equals("5") && !name.equals("6"));
}
while(row>5);
for(int i=0;i<6;i++)
{
if(seats[row-1].getName().equalsIgnoreCase(name))
{
if(seats[row-1].getVisible()==false)
{
System.out.println("\nThat seat is already taken, please select another one.\n");
j--;
}
{
seats[row-1].setVisible(false);
count++;
}
}
}
}
}
break;
case 2:
printArray(seats);
break;
case 0:
System.out.println("Good bye!");
break;
default:
//Informs the user that the input is not valid
System.out.println("Invalid input.");
break;
}
}
while(input != 0);
}
public static void printArray(Seat[][] a)
{
//Prints the rows
System.out.println("-SCREEN-");
for(int i=0;i<5;i++)
{
System.out.print(i+1+" ");
//Prints the seats
for(int j=0;j<6;j++)
{
System.out.print(a[j]);
}
System.out.print(" ");
System.out.println();
}
}
}
need help on this java coding...