The file you submit should be named “XYProjectTwo.java”, where “X” and “Y”
Copyright© 2022, Dallas College. All Rights reserved. Page 1 of 3
You have been hired to write a program that manages reserved seating for a small
off-Broadway theater. There are six rows in the theater. Each row contains eight
seats. The rows in the theater are identified by the letters A through F starting
from the front of the theater. The seats within each row are identified by the
numbers 1 through 8. Reservation information is to be stored in a two-dimensional
integer array. The value one (1) will be used to indicate that a seat has been
reserved. The value zero (0) will be used to indicate that a seat has not been
reserved. The array should be initialized to zeroes before presenting the following
menu to the user the first time.
Your program will repeatedly present the user with the following choices:
Option Action
—— ————–
1 Clear all reservations.
2 Read reservations from a file.
3 Make a reservation.
4 Save seating chart to a file.
5 Quit.
Enter your choice:
When the user selects option 1, your program will assign the value zero (0) to all
the elements in the array.
When the user selects option 2, your program will ask the user to identify a file,
open and read the file, and use the records in the file to store reserved seating
information. The file will be a text file that contains six records, one for each of the
six rows in the theater. Each record will contain eight integer values, one for each
seat in that row. The values will be separated from each other by one or more
blanks. A typical record looks like this:
0 1 1 0 0 1 1 0
After opening, reading, and processing the file, your program will display a
message indicating how many seats have been reserved as a result of that
processing. That message should look something like this:
24 reserved seats have been loaded.
When the user selects option 3, your program will accept a single line of keyboard
input from the user in the form of a letter identifying the desired row and the
desired seat number in that row separated from the row letter by a blank. For
example, when the user wants to indicate that a reservation should be made for
seats 6 and 7 in row D, they will enter:
D 6
D 7
Copyright © 2022, Dallas College. All Rights reserved. Page 2 of 3
Your program will do the following:
• Validate the user’s input. Valid rows are letters from A through F, either
upper-case (A, B, C, D, E, F) or lower-case (a, b, c, d, e, f). Valid seat
numbers range from 1 through 8. If the user inadvertently enters an invalid
seat identification, inform them, and allow them to make a correct entry.
(Hint: Refer to section 4.3 of our textbook, entitled “Using the while Loop
for Input Validation”.)
• If the user enters a valid seat identification, determine if that seat has
already been reserved. If it has, inform the user, and display the main menu
again, allowing them to reserve a different seat. Otherwise, mark that seat
as reserved.
When the user selects option 4, your program will ask the user to enter a month
and day string that identifies this set of reservations. The program will then create
a seating diagram and write it to a text file named Seating.txt. Your program will
display a brief summary to the screen repeating the reservation date that was
entered by the user and showing the total number of seats reserved for that date.
A typical screen report would look like this after the user indicates that this set of
reservations is for February 23:
42 seats reserved for February 23
The seating chart will display reserved seats as the value 1, seats that have not
been reserved will be displayed as a 0. The report will include the total number of
seats that have been reserved for each row as well as the total of seats reserved
for that date. A typical seating report looks like this:
Seating Chart for February 23
Prepared: Sat Jan 29 08:05:30 CST 2022
Row ———————— Total
A 0 0 0 1 1 0 1 0 3
B 0 0 0 1 1 0 1 0 3
C 0 0 0 1 1 0 1 0 3
D 0 0 1 1 1 1 1 0 5
E 0 1 0 1 1 1 1 0 5
F 1 0 0 1 1 0 1 1 5
24 seats reserved for February 23
When the user selects option 5, the program will terminate.
Start early. Test your program. Your instructor will run your program to help
determine your grade for this assignment.
Copyright © 2022, Dallas College. All Rights reserved. Page 3 of 3
To receive full credit for this programming assignment, you must:
• Use the correct file name. For example, a student named John Jones will
name his file, “JJProjectTwo.java”.
• Submit a program that executes correctly. (No syntax or execution errors)
Grading Guideline:
• Correctly name the file that is submitted. (5 points)
• Include a comment containing the student’s full name in the program. (5
points)
• Store the reserved seating information in an integer two-dimensional array
that has the appropriate number of rows and columns. (10 points)
• Repeatedly display the specified menu choices. (10 points)
• Validate the menu choice entered by the user. (5 points)
• Correctly reads and processes a user specified file as part of menu choice 2.
(10 points)
• Reports the number of seats reserved as a result of processing a file. (5
points)
• Validates the row and seat number entered as part of menu choice 3. (10
points)
• Correctly determines if a seat has already been reserved as part of menu
choice 3. (5 points)
• Prompts the user for a reservation date string as part of menu choice 4. (5
points)
• Writes seating chart information correctly to a file named Seating.txt (10
points)
• Output file contains correct row totals and an overall total. (10 points)
• Output contains the current date and time. (5 points)
• Program terminates when option 5 is selected. (-5 points)
- Project Two, Theater Seating
Copyright © 2022, Dallas College, All Rights Reserved Page 1 of 2
Creating the solution to a programming problem is not an exercise in finding
an answer on the Internet and submitting it as your own work. Submitting
someone else’s work as your own is plagiarism. Plagiarism is an example of
Scholastic Dishonesty. Copying all or part of a solution from a web site is
plagiarism.
Worse, you have not learned anything about how to use a computer
program to solve a problem. You are always far better off submitting your
own original work. You will always be given credit for attempting to solve the
problem. On the other hand, if plagiarism is detected, you will receive a
grade of zero (0).
Start early. Read the book. Ask for help if you get stuck. Do your own work.
Do not share your work with any other students. Do not ask any other
students to share their work. There are no group projects in this course.
In Programming Project Two you are asked to create a two-dimensional
array, store values in some of the elements of the array and use these
values to display a report. The report will show the contents of each of the
elements in the array as well as row totals and an overall total.
In Section 7.9 of our textbook, we learn that a two-dimensional array is
actually a one-dimensional array in which each element is another one-
dimensional array. The length attribute of a two-dimensional array object is
the number of rows in that two-dimensional array. Your textbook contains all
the details and good examples of how to perform all the required activities
required in this assignment.
Spend some time examining Code Listing 7-19 (Lengths.java) where the
program uses the length fields of a two-dimensional array to determine and
display the number of rows and the number of columns in each row.
Following that example program in our textbook are text discussions and
example code for determining the row and column totals for a two-
dimensional array.
Another useful example program can be found in Code Listing 7-20
(Pass2Darray.java) where the program demonstrates passing a two-
dimensional array to a method. That example program also demonstrates
how to determine the sum of all the elements in a two-dimensional array.
Copyright © 2022, Dallas College, All Rights Reserved Page 2 of 2
Section 4.3 of our textbook is entitled “Using the while Loop for Input
Validation”. Validate user input when they enter their menu choice as well as
when they identify a seat to be reserved.
Characters are stored using Unicode in Java. If you add one (1) to the
character representation of upper-case ‘A’, you get upper-case ‘B’. Add one
more to get upper-case ‘C’, and so on.
A good way to control the formatting of your output is by using the printf
method. The syntax to invoke this method is as follows:
System.out.printf(format, item1, item2, . . ., itemN);
Where format is a string that consists of format specifiers. The items that
are to be displayed by the format specifiers must match the specifiers in
order, in number, and in exact data type. Common format specifiers are:
• %c a character, for example ‘a’
• %d a decimal integer, for example 200
• %f a floating-point number, for example 45.4600
• %s a string, for example “Java is cool”
• %n a newline character (‘\n’)
Field width and precision can also be specified as well as adding comma
separators. These statements produce the following output:
System.out.println(“——-+——-+——-+”);
System.out.printf(“%,8d%8s%8.1f\n”, 1234, “Java”, 34.56);
Output:
——-+——-+——-+
1,234 Java 34.6
The printf method does not automatically supply a new line character (\n).
This will allow you to “build up” output one item at a time before proceeding
to the next line to be displayed.
A suggested way to obtain and print the date and time is:
// Obtain the current date/time
Date now = new Date();
outputFile.println(“Prepared: ” + now.toString());
- Helpful Tips for Programming Project Two
0 0 0 1 1 0 1 0
0 0 0 1 1 0 1 0
0 0 0 1 1 0 1 0
0 0 1 1 1 1 1 0
0 1 0 1 1 1 1 0
1 0 0 1 1 0 1 1