Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can you write this in java fallowing these specs? 1. A hotel's occupancy rate is calculated as follows Occupancy rate = Number of rooms occupied

image text in transcribedcan you write this in java fallowing these specs?

1. A hotel's occupancy rate is calculated as follows Occupancy rate = Number of rooms occupied / Total number of rooms Write a program that calculates the occupancy rate for a hotel. The program should start by asking for the number of floors in the hotel. A loop should then iterate once for each floor. During each iteration, the program should ask the user for the number of rooms on the floor and how many of them are occupied After all iterations have completed, the program should display the total number of rooms at the hotel, the number of rooms currently occupied, and the occupancy rate for the hotel. The occupancy rate should be displays as a percentage Input validation is required. Do not accept a value less than 1 for the number of floors. Do not accept a number less than 10 for the number of rooms on a floor. And, the number of rooms occupied must be less than or equal to the number of rooms available. When invalid data is given, display an error message and allow the user to re-enter the value Example run 1 Enter the number of floors for this hotel: 2 How nany rooms are on floor 1? 10 How many of these rooms are occupie How many rooms are on tloor 2? 10 How nany of theae rooms are occupied? 10 d? 5 Total number of rooms 20 The number of rooms occupied: 15 Occupancy rate: 75.00% Example run 2 1/3 1/30/2018 Lab 3 Enter the number of florg for this hotel: -5 The number of floora can not be negative! Try again Enter the numbcr of floors for this hotel: 2 How many rooms re on floor 1? 2 Number of rooms must be greater than 10 Try again HoW many rooms are on floor 1? 10 Ho many of theae rocms are occupied? 20 value nust be >_ 0 and

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

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

Degree to which the problem can be modularized

Answered: 1 week ago