Question
Write a Java class representing the concept of Hotel Rating over a number of years. The hotel ratings are represented by a number of stars:
Write a Java class representing the concept of Hotel Rating over a number of years. The hotel ratings are represented by a number of stars: one star (lowest quality) to five stars (highest quality). The only attribute 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. Write the following class methods:
A constructor method that takes two parameters representing the number of hotels and the number of years. The ratings are randomly generated and stored in the array.
Method bestHotel that returns an array of 2 elements holding the index for the best quality hotel over the years and the index for the worst quality hotel over the years.
Method printChart that prints a rating chart for all hotels similar to the following sample output (just for illustration, assume we have 3 hotels and 4 years of ratings):
Hotel 0: ** *** **** ***
Hotel 1: *** *** ** **
Hotel 2: ***** **** **** *****
Write a test program to create an object of the class and test all of the class methods on that objects.
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