You are on page 1of 6

MULTI-DIMENSIONAL PROGRAMS

Be sure to include any pre and post conditions if you use any methods. Be sure that
ALL methods and segments must be commented thoroughly and meet the
programming expectations.
1. The Jenkins Basketball Team is vying for top spot. The team is
playing Camden and plan to take a fan bus. Your job is to write a
program to ask the user how big the bus is (number of rows and
number of seats across (columns)). You will be asking the user
where he/she would like to sit (row and column) and his/her
name. See if the seat is available (based on what you set it to). If the seat is
available reserve the seat -- if the seat is not available have the user choose
another. You will have to allow the user to continue choosing seats until he/she
wishes to quit OR until all the seats are taken (hint count when a seat is taken).
Create a main class called Reservations.
Your main class should do the following
Get the size of the bus
initialize your bus object (using your subclass)
Ask the user whether they would like to reserve a seat
Get the information regarding the reservation (be sure to error
trap)
When the user is done print out the bus
Write a subclass called ReserveSeat
Instance data should be declared as a bus
private String [][] bus; //declares bus but does not instantiate it
Constructor--Your constructor should take in two parameters
(the number of rows and the number of columns)

In your constructor you should instantiate your


array bus based on the number of rows and
columns

//instantiate the bus


bus = new String[numRows][numCols];
Initialize all of the seats in the bus how
will you know if the seat is empty

METHODS of SeatReservations
ReserveSeat returns a Boolean value of whether
the seat was reserved the formal parameters are
the persons name, row, and column. If the seat is
reserved the persons name should be placed in
the array. Make sure that you do not try to overfill
the busprint an error message if the bus is
already full.
toString will print out the array so that you know who is sitting where (be
sure that you include a title before you print) (you could put tabs
between to format (\t)
ex.
Jenkins Fan Bus Seating
Joe
Sam
Tim
empty
empty
Sally
Tom
Megan

2. You have been hired by the Weather Bureau to create a program


resortWeather that asks how many resorts there will be data for and
the number of years the snowfall has been recorded.
Your main class should do the following
Get the number of resorts and the number years
example
How many resorts? 3
How many years? 5
initialize your weather object (using your subclass)
Ask the user what report they would like
process the report
Continue until the user wishes to quit
This number of resorts and years will be passed into your constructor. Where you
will build and fill your arrays.
You will need to create arrays that will have to have 4 rows. In the first row, it will
hold the word resort. The first row of snowfall array will hold the year of the
snowfall.

Write a subclass called snowReport


Instance data should be declared as a skiLodge,
private String [][] skiLodge; //declares skiLodge but does not
instantiate it
private int [][] snowReport; //declares snowReport but does
not instantiate it
Constructor--Your constructor should take in two parameters
(the number of resorts and the number of years)
In your constructor you should instantiate your arrays
based on the number of resorts and years
//instantiate the arrays
skiLodge = new String[resorts + 1]; we need an
extra row for the years
PUT THE WORD RESORT IN LOCATION 0;
skiLodge[0] = RESORT;
snowReport = new int[resorts + 1][years]; we
need an extra row for the years

Ask the user which years you are recording data


for and fill the first row of snowReport
Example (from the example of 5)
Enter year 1? 2009
Enter year 2? 2010
Enter year 3? 2011
Enter year 4? 2012
Enter year 5? 2013
The arrays will now look like this (hint places
these values in row 0 for the corresponding
arrays). Once you have done that you will use a
loop to fill the other locations.

RESORT
skilodge

2009 2010 2011 2012 2013


snowReport

You will then loop, IN THE CONSTRUCTOR, to ask the user for the resort name and
loop to input the snowfall for each year for that resort (hint--nested loops).
what your arrays may look like after the constructor is finished!

skilodge

resort
SnowBowl
KneeDeep
WaistHigh

snowReport

2009
106
143
136

2010
147
151
143

2011
139
134
130

2012
153
117
142

2013
126
139
145

METHODS of snowReport
resortAverage takes a string parameter that corresponds
to the name of a ski resort. The method returns that
average snowfall for that resort. If the resort is not found a
-1 should be returned.
yearAverage takes an integer parameter that corresponds
to one of the years. The method returns that average
snowfall for that year. If the year is not found a -1
should be returned.
yearResort takes an integer parameter that corresponds to one of the
years and a String parameter that corresponds to one of the resorts. The
method returns the snowfall for that resort and that year. If the year or
the resort is not found a -1 should be returned.
toString will print out the arrays so that you know what is in the ski
report. Use the /t escape sequence to tab

SKI REPORT
RESORT
2009
SnowBowl
106
KneeDeep
143
WaistHigh
136

2010
147
151
143

2011
139
134
130

2012
153
117
142

2013
126
139
145

In your driver class, the user should be able to enter the name of the resort you
want to know the average snowfall for or the year that the user wants to know the
average snowfall.

DRIVER CLASS--REQUIREMENTS
After creating the object, your driver class should ask the user the following
What report would you like?
1. RESORT REPORT
2. YEAR REPORT
3. SPECIFIC REPORT (RESORT/YEAR)
4. PRINT SKI REPORT
5. QUIT (they must quit to end the program)

Examples
User enters a 1
What resort are you looking for?
KneeDeep
using your method from snowReport
The average snowfall is 136.8 inches

User enters a 1
What resort are you looking for?
Whistler
using your method from snowReport
would return -1 because that resort is not found HAVE AN APPROPRIATE
MESSAGE

User enters a 2
What year are you looking for?
2011
using your method from snowReport
The average snowfall is 134.3 inches

User enters a 2
What year are you looking for?
2014
using your method from snowReport
would return -1 because that year is not foundHAVE AN APPROPRIATE
MESSAGE

User enters a 3
What year are you looking for?
2010
What resort are you looking for?
KneeDeep
using your method from snowReport
The 2010 snow report for KneeDeep is 151

User enters a 5
Thank you for using Ski Resort.com

You might also like