Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am working on a theatre seat assignment and i want to make a change. The follo

ID: 3686089 • Letter: I

Question

I am working on a theatre seat assignment and i want to make a change.

The following method prints 0 in the place of the price the user chooses, however i want it to print XX(which is a string or can be a char) in that place. However my array is an integer.

PLEASE HELP.

public static void sellSeatByNumber(int seatingChart[][])

   {

int col = 0;

   System.out.println("Enter row: ");

   int row = in.nextInt();

   row = Math.abs(row-9);

   System.out.print("Enter seat: ");

   col = in.nextInt();

   col -= 1;

   if (seatingChart[row][col]!=0)

   {

   seatingChart[row][col] = 0;

   printSeats(seatingChart);

   System.out.println("Your seat has been reserved and reflected with a 0 on the chart now.");

   }

   else { System.out.println("That seat is already taken, please try again"); }

   }

}

public static void printSeats(int seatingChart[][])

   {

   int row = 9;

   for(int i=0; i<seatingChart.length; i++)

   {

       System.out.print("Row "+ row+ " ");

   for(int j=0; j<seatingChart[i].length; j++)

   {

   if (j>0)

       System.out.print(" ");

   System.out.print(seatingChart[i][j]);

   //System.out.println();

   }

   row--;

   System.out.println();

   }

   }

Explanation / Answer

//This prints XX in chosen and YY in not chosen seats

public static void sellSeatByNumber(int seatingChart[][])
{
int col = 0;
System.out.println("Enter row: ");
int row = in.nextInt();
row = Math.abs(row-9);
System.out.print("Enter seat: ");
col = in.nextInt();
col -= 1;
if (seatingChart[row][col]!=0)
{
seatingChart[row][col] = 0;
printSeats(seatingChart);
System.out.println("Your seat has been reserved and reflected with a XX on the chart now.");
}
else { System.out.println("That seat is already taken, please try again"); }
}
}
public static void printSeats(int seatingChart[][])
{
int row = 9;
for(int i=0; i<seatingChart.length; i++)
{
System.out.print("Row "+ row+ " ");

for(int j=0; j<seatingChart[i].length; j++)
{
if (j>0)
System.out.print(" ");
if(seatingChart[i][j]==0)
System.out.print("XX");
else
System.out.print("YY");
//System.out.println();
}
row--;
System.out.println();
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote