30
дек
30
дек
Write a program that assigns seats on an airplane. Suppose the airplane has 20 seats in first class (5 rows of 4 seats each, separated by an aisle) and 90 seats in economy class (15 rows of 6 seats each, separated by an aisle).
There are couple mistakes in your code. 1) When you said first 2 rows, in array data type, it means 0 & 1 indices because array uses 0 index (value from 0 up to array_length-1).
In your code, line 17 for example, is going through 0, 1, and 2 which means the first 3 rows, not 2. 2) If you are going to assign 1 to each seat, you should use matrix[i][j]=1; instead of matrix[i][j]++.
3) The reason it assigns all to 1 because of lines 80~88. You did not decrease the number of seat after you assign a seat to your matrix. As a result, every seat is assigned because the number of seat will always be greater than 0. 4) I am not sure what the purpose of firstClass() method. Rogue squadron patch xp download.
Now question. Do you automatically assign seat for users? The reason I ask is because your current program attempts to do so without checking whether the seat is already assigned.
Thx all for replying this is the purpose of the methods copide fro the assignment. • Book First Class Seats: This option is used when a customer want to reserve First Class Seats in Air Plane, Rows 1 and 2 are reserved for First Class, you have to make sure that if the seat is available, you will allow customer to reserve seats in First Class, Customer can reserve more than one seats (User will enter seats in all the cases).
To solve this option you have to use a method and signature of the method is given underneath public static double firstClass(int [][] airplane, int seats, double price) where airplane is a 2-D Array and seats is the number of seats customer want to reserve and price is the price of one seat. This method will reserve seats in first class only, if requested seats are available and return total amount customer has to pay for his seats. This method returns -1 in case seat is not available. • Book Business Class Seats: This option is used when a customer want to reserve Business Class Seats in Air Plane, Rows 3 and 7 are reserved for Business Class, you have to make sure that if the seat is available, you will allow customer to reserve seats in Business Class, Customer can reserve more than one seats. To solve this option you have to use a method and signature of the method is given underneath public static double businessClass (int [][] airplane, int seats, double price) where airplane is a 2-D Array and seats is the number of seats customer want to reserve and price is the price of one seat.
This method will reserve seats in Business class only, if requested seats are available and return total amount customer has to pay for his seats. This method returns -1 in case seat is not available.
• Book Economy Class Seats: This option is used when a customer want to reserve Economy Class Seats in Air Plane, Rows 8 and 12 are reserved for Economy Class, you have to make sure that if the seat is available, you will allow customer to reserve seats in Economy Class, Customer can reserve more than one seats. To solve this option you have to use a method and signature of the method is given underneath public static double economyClass (int [][] airplane, int seats, double price) where airplane is a 2-D Array and seats is the number of seats customer want to reserve and price is the price of one seat. This method will reserve seats in Economy class only, if requested seats are available and return total amount customer has to pay for his seats.
This method returns -1 in case seat is not available. I didn't understand what you meant by decrease the seat. Currently it changs first 2 rows to 1 this is how it should be. And no it does'nt sign automatic it checks if seat is available or not. The code still has hardcoded numbers in the if statements. They shoukd be replaced by either the array's length attribute or by varialbes. For(int i =0;i.
I don't want it to be one always it needs to be like in the picture I think you cannot imagine how matrix is related to a plane seats right now. How about this.
Write a program that assigns seats on an airplane. Suppose the airplane has 20 seats in first class (5 rows of 4 seats each, separated by an aisle) and 90 seats in economy class (15 rows of 6 seats each, separated by an aisle).
There are couple mistakes in your code. 1) When you said first 2 rows, in array data type, it means 0 & 1 indices because array uses 0 index (value from 0 up to array_length-1).
In your code, line 17 for example, is going through 0, 1, and 2 which means the first 3 rows, not 2. 2) If you are going to assign 1 to each seat, you should use matrix[i][j]=1; instead of matrix[i][j]++.
3) The reason it assigns all to 1 because of lines 80~88. You did not decrease the number of seat after you assign a seat to your matrix. As a result, every seat is assigned because the number of seat will always be greater than 0. 4) I am not sure what the purpose of firstClass() method. Rogue squadron patch xp download.
Now question. Do you automatically assign seat for users? The reason I ask is because your current program attempts to do so without checking whether the seat is already assigned.
Thx all for replying this is the purpose of the methods copide fro the assignment. • Book First Class Seats: This option is used when a customer want to reserve First Class Seats in Air Plane, Rows 1 and 2 are reserved for First Class, you have to make sure that if the seat is available, you will allow customer to reserve seats in First Class, Customer can reserve more than one seats (User will enter seats in all the cases).
To solve this option you have to use a method and signature of the method is given underneath public static double firstClass(int [][] airplane, int seats, double price) where airplane is a 2-D Array and seats is the number of seats customer want to reserve and price is the price of one seat. This method will reserve seats in first class only, if requested seats are available and return total amount customer has to pay for his seats. This method returns -1 in case seat is not available. • Book Business Class Seats: This option is used when a customer want to reserve Business Class Seats in Air Plane, Rows 3 and 7 are reserved for Business Class, you have to make sure that if the seat is available, you will allow customer to reserve seats in Business Class, Customer can reserve more than one seats. To solve this option you have to use a method and signature of the method is given underneath public static double businessClass (int [][] airplane, int seats, double price) where airplane is a 2-D Array and seats is the number of seats customer want to reserve and price is the price of one seat.
This method will reserve seats in Business class only, if requested seats are available and return total amount customer has to pay for his seats. This method returns -1 in case seat is not available.
• Book Economy Class Seats: This option is used when a customer want to reserve Economy Class Seats in Air Plane, Rows 8 and 12 are reserved for Economy Class, you have to make sure that if the seat is available, you will allow customer to reserve seats in Economy Class, Customer can reserve more than one seats. To solve this option you have to use a method and signature of the method is given underneath public static double economyClass (int [][] airplane, int seats, double price) where airplane is a 2-D Array and seats is the number of seats customer want to reserve and price is the price of one seat. This method will reserve seats in Economy class only, if requested seats are available and return total amount customer has to pay for his seats.
This method returns -1 in case seat is not available. I didn\'t understand what you meant by decrease the seat. Currently it changs first 2 rows to 1 this is how it should be. And no it does\'nt sign automatic it checks if seat is available or not. The code still has hardcoded numbers in the if statements. They shoukd be replaced by either the array\'s length attribute or by varialbes. For(int i =0;i.
I don\'t want it to be one always it needs to be like in the picture I think you cannot imagine how matrix is related to a plane seats right now. How about this.
...'>Airplane Seats Program Java(30.12.2018)Write a program that assigns seats on an airplane. Suppose the airplane has 20 seats in first class (5 rows of 4 seats each, separated by an aisle) and 90 seats in economy class (15 rows of 6 seats each, separated by an aisle).
There are couple mistakes in your code. 1) When you said first 2 rows, in array data type, it means 0 & 1 indices because array uses 0 index (value from 0 up to array_length-1).
In your code, line 17 for example, is going through 0, 1, and 2 which means the first 3 rows, not 2. 2) If you are going to assign 1 to each seat, you should use matrix[i][j]=1; instead of matrix[i][j]++.
3) The reason it assigns all to 1 because of lines 80~88. You did not decrease the number of seat after you assign a seat to your matrix. As a result, every seat is assigned because the number of seat will always be greater than 0. 4) I am not sure what the purpose of firstClass() method. Rogue squadron patch xp download.
Now question. Do you automatically assign seat for users? The reason I ask is because your current program attempts to do so without checking whether the seat is already assigned.
Thx all for replying this is the purpose of the methods copide fro the assignment. • Book First Class Seats: This option is used when a customer want to reserve First Class Seats in Air Plane, Rows 1 and 2 are reserved for First Class, you have to make sure that if the seat is available, you will allow customer to reserve seats in First Class, Customer can reserve more than one seats (User will enter seats in all the cases).
To solve this option you have to use a method and signature of the method is given underneath public static double firstClass(int [][] airplane, int seats, double price) where airplane is a 2-D Array and seats is the number of seats customer want to reserve and price is the price of one seat. This method will reserve seats in first class only, if requested seats are available and return total amount customer has to pay for his seats. This method returns -1 in case seat is not available. • Book Business Class Seats: This option is used when a customer want to reserve Business Class Seats in Air Plane, Rows 3 and 7 are reserved for Business Class, you have to make sure that if the seat is available, you will allow customer to reserve seats in Business Class, Customer can reserve more than one seats. To solve this option you have to use a method and signature of the method is given underneath public static double businessClass (int [][] airplane, int seats, double price) where airplane is a 2-D Array and seats is the number of seats customer want to reserve and price is the price of one seat.
This method will reserve seats in Business class only, if requested seats are available and return total amount customer has to pay for his seats. This method returns -1 in case seat is not available.
• Book Economy Class Seats: This option is used when a customer want to reserve Economy Class Seats in Air Plane, Rows 8 and 12 are reserved for Economy Class, you have to make sure that if the seat is available, you will allow customer to reserve seats in Economy Class, Customer can reserve more than one seats. To solve this option you have to use a method and signature of the method is given underneath public static double economyClass (int [][] airplane, int seats, double price) where airplane is a 2-D Array and seats is the number of seats customer want to reserve and price is the price of one seat. This method will reserve seats in Economy class only, if requested seats are available and return total amount customer has to pay for his seats.
This method returns -1 in case seat is not available. I didn\'t understand what you meant by decrease the seat. Currently it changs first 2 rows to 1 this is how it should be. And no it does\'nt sign automatic it checks if seat is available or not. The code still has hardcoded numbers in the if statements. They shoukd be replaced by either the array\'s length attribute or by varialbes. For(int i =0;i.
I don\'t want it to be one always it needs to be like in the picture I think you cannot imagine how matrix is related to a plane seats right now. How about this.
...'>Airplane Seats Program Java(30.12.2018)