Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old May 10th, 2006, 1:22 PM   #1
NightShade01
Programmer
 
Join Date: Oct 2005
Posts: 52
Rep Power: 4 NightShade01 is on a distinguished road
Multi array question

Just wanted to know if anyone will look over my code for me. The program is suppose to display a seating chart for an airplane:
1 A B C D
2 A B C D
3 A B C D
4 A B C D
5 A B C D
6 A B C D
7 A B C D
It should then prompt the user for their seat choice and then replace their choice of seat with an "X" signaling that the seat is taken. Choice of "Q" exits the program. Having a problem displaying the seating chart though. Any suggestions?

import java.util.*:  //import the scanner class

public class Seating{

	boolean taken = false;  //seat intial value is untaken

public String SeatWarn(){
	return "Seat Taken, please choose another seat."  //warn if your seat is taken
}

public void seatTaken(int x, int y){  //change the value of a seat to taken when necessary
	taken = true;
	seats[x][y] = "X";
}

public static void main(String [] args){  //create and display the seating chart
	int counter = 0;
	int[] seats = new int[5][7];
	int row, column;
	for(row = 0; row < seats.length; row++){
		for(column = 0; column < seats[row].length; column++){
			System.out.println(seats[row][column]);
		}
	}
while (count < 36){  //while there are chairs left

Scanner kb = new Scanner(System.in);
System.out.prinln("Please choose a row to sit in:");  //prompt for a row
int rowChoice = kb.nextInt();

System.out.println("Please choose a seat to sit in: (""q"" to exit");  //prompt for a seat
char seatChoice = kb.nextChar();
if (seats[rowChoice][seatChoice].taken = true){  //update the seating chart to reflect seat choosen
	SeatWarn();
}else{
seats[rowChoice][seatChoice].seatTaken(x,y);
}  //Loop

}
NightShade01 is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:50 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC