Making an airplane seating map and the code does not break after the number 88 is selected and does not print our the array, any help? Thanks

import java.util.*;
import java.util.Scanner;  



public class AirplaneSeats 
{


public static void main(String[] args) 
{
char[][] seats = new char[13][4];  
char filledseat = 'x'; 

for (int i = 0; i < 13; i++) {
	seats[i][0] = 'A';  
	seats[i][1] = 'B';
	seats[i][2] = 'C';
	seats[i][3] = 'D';
	}  
Scanner keyboard = new Scanner(System.in); 

int filled = 0; 
int row;
int column; 
int moreseats;  

printAirplaneSeats(seats);
// Keep asking for seats until seats are filled
System.out.println("Enter row number between 1 and 13."); 
row = (keyboard.nextInt()-1); 
	
System.out.println("Enter column number between 1 and 4."); 
column = (keyboard.nextInt()-1);
 
System.out.println("If you do not want another seat, please enter 88 to exit."); 
System.out.println("If you still want to enter more seats please enter 100."); 
moreseats = keyboard.nextInt(); 
	if(moreseats == 88)
	{ 
	System.out.println("You entered 88, no more seats.");                                 
			}
			
			 do
			 {
				for (filled= 0; filled <52; filled++)
				{
				seats[row][column] = filledseat; 
				
				if (filled < 52)
				{
				System.out.println("If you do not want another seat, please enter 88 to exit."); 
				System.out.println("If you still want to enter more seats please enter 100."); 
				moreseats = keyboard.nextInt();
				
				if (moreseats == 88)
				{ 
				System.out.println("You entered 88, no more seats.");
				break;
				}
				
			
				System.out.println("Enter row number."); 
				row = (keyboard.nextInt()-1); 
				System.out.println("Enter column."); 
				column = (keyboard.nextInt()-1); 
				}
			}
		printAirplaneSeats(seats);
		}
	
			 while (moreseats == 100); 
			  System.out.println("Final seat assignments are: "); 
				printAirplaneSeats(seats); 
			}
			public static void printAirplaneSeats(char[][] seats)
			{
				for (int i = 0; i < seats.length; i++)
				{
					 System.out.println((i + 1) + "   " +
					 seats[i][0] + " " + seats[i][1] + "  " +
					   seats[i][2] + " " + seats[i][3]); 
					   }
			  
				
			}
	}
if(moreseats == 88)
{ 
    System.out.println("You entered 88, no more seats.");
}

just using a println will not stop operations that should come after it try using a loop then use a break when 88 is entered

the problem with the arrays lies within the loops try to trace your code

actually.. most of your problems will come from the loops you've made maybe rewrite your code and trace each step

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.