In Java programing language Debug this program public class Main { public static
ID: 3908362 • Letter: I
Question
In Java programing language Debug this program public class Main { public static void main (String[] args) { Scanner scan=new Scanner(System.in); Seat[][]array=new Seat[7][4]; Seat desiredSeat; int count=0; int row; String name; for (int i = 0; i<7; i++){ array[i][0]=new Seat("A"); array[i][1]=new Seat("B"); array[i][2]=new Seat("C"); array[i][3]=new Seat("D"); } do{ do{ printArray(array); System.out.println("Which place do you want to take: "); row=scan.nextInt(); name=scan.next(); }while(row>7); for(int i=0;i<4;i++){ if(array[row-1][i].getName().equalsIgnoreCase(name)){ if(array[row-1][i].getVisible()==false){ System.out.println("The seat is already taken, please select another one."); } else{ array[row-1][i].setVisible(false); count++; } } } }while(count!=28); printArray(array); System.out.println("All seats have been sold!!!"); } public static void printArray(Seat[][] a){ for(int i=0;i<7;i++){ System.out.print(i+1+" "); for(int j=0;j<4;j++){ System.out.print(a[i][j]+" "); } System.out.println(); } } }
Explanation / Answer
======================================================
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.