Java Reference
In-Depth Information
11. Write a program to assign passengers seats in an airplane. Assume a small airplane
with seat numberings as follows:
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
The program should display the seat pattern, with an 'X' marking the seats already
assigned. For example, after seats 1A, 2B, and 4C are taken, the display should look
like the following:
1 X B C D
2 A X C D
3 A B C D
4 A B X D
5 A B C D
6 A B C D
7 A B C D
After displaying the seats available, the program should prompt for the seat desired,
the user can type in a seat, and then the display of available seats should be updated.
This continues until all seats are filled or until the user signals that the program
should end. If the user types in a seat that is already assigned, the program should
say that that seat is occupied and ask for another choice.
12. Write a program that plays a simple trivia game. The game should have five ques-
tions. Each question has a corresponding answer and point value between 1 and
3 based on the difficulty of the question. Implement the game using three arrays.
An array of type String should be used for the questions. Another array of type
String should be used to store the answers. An array of type int should be used
for the point values. All three arrays should be declared to be of size 5.
The index into the three arrays can be used to tie the question, answer, and point
value together. For example, the item at index 0 for each array would correspond
to question 1, answer 1, and the point value for question 1. The item at index 1
for each array would correspond to question 2, answer 2, and the point value for
question 2, and so forth. Manually hardcode the five questions, answers, and point
values into your program using trivia of your choice.
Your program should ask the player each question one at a time and allow the
player to enter an answer. If the player's answer matches the actual answer, the
player wins the number of points for that question. If the player's answer is incor-
rect, the player wins no points for the question. Your program should show the
correct answer if the player is incorrect. After the player has answered all five ques-
tions, the game is over, and your program should display the player's total score.
Search WWH ::




Custom Search