hello everyone need help with my program this is a airplane seating program for reservations it's a 2d array of 000 .. and when i take a seat it changs to 1 we have first class supposed to be first 2 rows and rows 3 to 7 are business class, and rows 8 to 12 are economy class ..
what i am reallly having problem with is when i enter number of seats i want to change values of the array form 0 to 1 depending on number of seats currently he changes all values to 1 :(
i need to finish it by tommorow plz help ..
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package airplane.seating;
import java.util.Scanner;
import sun.security.util.Length;
/**
*
* @author Home
*/
public class AirplaneSeating {
public static double firstClass(int [][] airplane, int seats, double price)
{
boolean emptySit = false;
for(int i =0;i<3;i++)
{
for(int j = 0;j<7;j++)
{
if (airplane[i][j] == 0)
{
emptySit = true;
}
if(emptySit)
{
airplane[i][j] = 1;
}
else
{
airplane[i][j] = 0;
}
System.out.print(airplane[i][j] + " ");
}
System.out.println();
}
return price;
}
public static void displaySeat(int [][] airplane)
{
System.out.println("-------------------------------------------");
for(int i =0;i<airplane.length;i++)
{
for(int j = 0;j<airplane[i].length;j++)
{
System.out.print(airplane[i][j] + " ");
}
System.out.println();
}
System.out.println("-------------------------------------------\n");
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int [][] matrix = new int[12][7];
System.out.println("Welcome To The Airplane Managment System");
System.out.println("-------------------------------------------\n" +
"1. Book First Class Seats\n" +
"2. Book Buisness Class Seats\n" +
"3. Book Economy Class Seats\n" +
"4. View air Plane Seating assignment\n" +
"5. Know Fair\n" +
"6. System Reset\n" +
"7. Exit From The Booking System\n" +
"Enter Your Choice :" );
int choice = input.nextInt();
switch(choice)
{
case 1:
System.out.println("Enter How Many seats you want to book in First Class ?");
int seat = input.nextInt();
double price=seat * 1050;
for(int i =0;i<3;i++)
{
for(int j = 0;j<7;j++)
{
if (seat > 0) {
matrix[i][j]++;
} }
}
System.out.println("Total Fair of the booking is " + price);
firstClass(matrix,seat,price);
break;
//Displaying Matrix
case 4:
displaySeat(matrix);
break;
}
}
}