Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create a new class file named ResortAccommodations.java in Grasp or Eclipse 2. Import the Scanner at the top of your program 3. Write the

image text in transcribed
image text in transcribed
1. Create a new class file named ResortAccommodations.java in Grasp or Eclipse 2. Import the Scanner at the top of your program 3. Write the Class comment and author and @version tags 4. Declare and open your class named Resort Accommodations 5. Declare and open the main method 1. Create a Scanner object in to read the input from the console 2. Declare two (2) int variables for total number of rooms and total number of occupied rooms and initialize each to 0. We will use these later in the program. 3. Prompt the user to enter the number of floors the resort contains and use the Scanner class methods to store the response in appropriate variables. (see Sample Output). . Use a while loop to validate that the number of floors is greater than or equal to 1. If it is not, output an "invalid" message and prompt the user to enter again. Store the response in the variable from #3. 4. Use a for loop (that counts from 0 to the variable from #3) to prompt for the number of rooms on each floor (notice the prompt in the Sample Output has the floor number - do not hard-code - use your counting int variable, i). Store the response in an appropriate variable. Inside the for loop, validate the number of rooms is greater than 10 using a while loop. If not greater than 10, output an invalid message and prompt again (see Sample Output). Store the response in your room variable. . Still inside the for loop, add the rooms to the total number of rooms variable created in #2. . Still inside the for loop, prompt the user the enter how many rooms are occupied for each floor and use the Scanner class methods to store the response in an appropriate variable. (see Sample Output). Still inside the for loop, use a while loop to validate that the occupiedrooms do no exceed the number of rooms. If they do, output an "invalid" message and prompt again. Store in the occupied variable created above. (see Sample Output). Still inside the for loop, add the occupied rooms to the total numberof occupied rooms vable created in #2. tastale vw.ing.edu Mercontent2244037MewCont41491108/ 12 5. Back in program (out of for loop), calculate the number of vacant rooms and store in an appropriate variable (i.e. total rooms - total occupied rooms). 6. Calculate the percent (%) rate of occupancy of the resort and store in an appropriate variable (this can be an int or double, so use the best variable). We can find the percent occupied by dividing the total number of occupiedrooms by the total number of rooms * 100. 7. Using print(In) or printf, output the Number of rooms, the Occupied rooms, the Vacant rooms, and the Occupancy rate to 2 decimal places. (See the Sample Output) 8. Close the main method and the class. 9. **Don't forget to comment your code for clarity. You may do this above statements or beside statements, but you can keep it brief. A simple explanation is fine

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

Students also viewed these Databases questions