Question
*HELP PLEASE* User Input program. Students will learn implement 2D arrays use static methods passing parameters to methods (arrays, etc) This assignment will help students
*HELP PLEASE* User Input program.
Students will learn
- implement 2D arrays
- use static methods
- passing parameters to methods (arrays, etc)
This assignment will help students practice
- using loops.
- declaring and using constants
- if statements
- comment methods and classes
The student will create a program Hotel.java using a 2D array to simulate a hotel.
Your program should
- be named Hotel.java
- use at least one 2D array. You may use a second 2D array, if correctly implemented and used in a meaningful way. You must document your rationale for using a second 2D array. No linear arrays are allowed.
- Must declare the 2D array rows/columns as a constants inside the main method
- Should not use any global variables. (40 points)
- You should not use any java provided utilities except for the arrays class utilities covered in this class.
- You should not use any other data structure aside from 2D arrays. (no arraylists no single dimensional arrays)
- The 2D array should be declared INSIDE the main method. IT should NOT be a global variable. This 2D array should be passed to any method that may need it. Note that you will also need to pass the size [rows] and [columns].
- You must comment/document the functionality of all methods used in this project (20 points)
- You should implement the methods listed below.
- Your code should not crash. Use try/catch and loop again until the user decides to exit.
Required static methods
- printAllEmptyRooms( parameters ) (40 points)
- printEmptyRoomsOfType( parameters ) (40 points)
- printRoomsByFloor( parameters ) (40 points)
- checkGuestIn( parameters ) (40 points)
- checkGuestOut( parameters ) (40 points)
Note that I left return values and parameters empty. Those decisions are up to you. However the 2D Array and the dimensions must be passed as parameters.
You may have other methods besides the above methods, but those methods should be implemented.
Array Details
The hotel has a total of 50 rooms in 5 floors Each floor has rooms ending in 01 up to 10 For example rooms in the third floor are 301, 302, 303 ... 310 Rooms ending in 01 are handicap rooms Rooms ending in [02..05] inclusive are single rooms Rooms ending in [06.. 10] inclusive are double rooms Rooms in the 5th floor are all deluxe rooms/ penthouse rooms, and still the other rules apply, meaning 501 is a handicap deluxe room, 502 to 505 are single deluxe and 506 to 510 are double deluxe rooms. Empty rooms will be represented by a -1 (invalid price) Any amount greater than -1 will represent the price per night for that room. $0 is a free room. Any other non-negative amount will signify that the room is occupied. In general, negative amounts represent an empty room. By default rooms in the 5th floor are all deluxe. Summarizing, There are 4 types of rooms 1. Handicap 2. Single 3. Double 4. Deluxe 0. Exit
Program Execution
When the program begins execution you should add a -1 to each position in the 2D array.
You should display the following menu: 1. print all empty rooms 2. print all empty rooms of a given type 3. print rooms on a given floor 4. check a guest in 5. check a guest out 0. end execution
The main method
- The above menu should be displayed.
- Option 1 - When booking a room you just need to go to that position and add a price 0.. $5K Option 2 - When checking out from a room just reset the price back to -1 Options 3, 4 and 5 all include loops
- You should use at least five different methods, one per option The array of double numbers must be passed on from method to method as a parameter along with any other parameters that may need to be passed on.
- You must make sure that your code will not crash when invalid input is entered The menu should continue to loop until the user selects 0 to exit Once this happens you should print a message before ending execution.
Output Formatting
- You must format any amounts that are displayed into the screen appropriately (example: room cost must have 2 decimals and the $ sign. You may also run into the issue of printing [FLOOR][ROOM] where you will need to add a leading zero to the room. In this case I recommend you use System.out.printf("%02D", number) you may use that printf also for the room cost. Proper output formatting (40 points)
- Note that this menu should be displayed after each user interaction with the program (10 points)
Executing the Code
When printing empty room numbers do it as follows Print them in order by floor If printing only one floor do it in ascending order You will only print the room number this option is meant to be used when looking for an empty room to book
When checking in Use option 2 to print the list of all empty rooms of the type the user "wants" (this is pretend) Select a room by entering the room number (you will use % and int division) Assign a price to the room (store the price in that slot to signify that the room is occupied) If an occupied room is selected by mistake you should print an error message if an non-existing room is selected by mistake you should print an error message loop back into the menu When checking out enter room number verify that the room was indeed occupied and get the price reset the room price back to -1 (you will use % and int division) You must use one two-dimensional array of double numbers No objects are necessary The use of one dimensional arrays will result in 80% deduction If the code does not compile it will result in 80% deduction
Your code should not crash. If it crashes it will result in deductions based on the severity of the issue.
User-friendliness/usability of your code (20 points)
Extra credit opportunity: Applicable towards the check-out option. If you list all the occupied rooms at checkout time so that the user may select from there you may get up to 20 extra credit points. You may use a separate method or incorporate this functionality within the checkout method.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started