Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program#1(25 points): Design and implement a Java class (name it HoteRating) to implement the concept of rating hotels over a number of years. The rating

image text in transcribed
Program#1(25 points): Design and implement a Java class (name it HoteRating) to implement the concept of rating hotels over a number of years. The rating is represented by a number of stars: one star (lowest quality) to five stars (highest quality). The only data field the class has is a two-dimensional array of values representing the quality ratings. Dimension 1 (rows) represents the hotels and dimension 2 (columns) represents the years. The class constructor method takes two parameters representing the number of hotels and the number of years. These values decide the size of the array (rows x columns). The ratings are randomly generated (between 1 and 5 inclusive) and stored in the array. The class defines the following methods: 1. A method named fiveStarsHotels 0 to return an array of the indices (index values) of hotels that 2. A method named averageRatings to print out the average rating (double value) for each hotel 3. A method fourOrMoreStars to printout the indices (index values) of hotels that have earned four 4. A method named anyFivestars) to return true if at least one hotel earned five stars for at least one 5. A method named bestHotel to return the index for the best quality hotel over the years. If more 6. A method named worstHotel ) to return the index for the worst quality hotel over the years. If more 7. A method named printChart to print the ratings for all hotels as shown below (for illustration have earned five stars at least once over the years over the years or more starts at least once year, false otherwise than one hotel, return the index of the first hotel in the array than one hotel, return the index of the first hotel in the array assume we have 3 hotels and 4 years of ratings): Yearl Year2 Year3 Year4 Hotel 0: Hotel 1: Hotel 2: Write a test program in a separate file, named TestHoteRating, to create an object of the class and test all seven class methods on that object. The outputs should be organized as follows (assuming three hotels and four years) Five stars hotels indices: 0, 2 Average Ratings are: Hotel 0 3.25 Hotel 1: 2.75 Hotel 2:.25 Four or more stars hotels indices: 0, 1, 2 Any five stars hotel? true Best hotel index:2 Worst hotel index: 1 Ratings chart: Yearl Year2 Year3 Year4 Hotel 0: Hotel 1: Hotel 2

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 Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago