0% found this document useful (0 votes)
27 views2 pages

Question

The document outlines the creation of a Resort class with attributes such as resortId, resortName, Category, resortPrice, and resortRating, along with their getters, setters, and a parameterized constructor. It also describes a Solution class with a main method that implements a static method findAvgPrice to calculate the average price of resorts based on category and rating criteria. The main method reads resort data from user input and prints the average price or a message if no matching resorts are found.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Question

The document outlines the creation of a Resort class with attributes such as resortId, resortName, Category, resortPrice, and resortRating, along with their getters, setters, and a parameterized constructor. It also describes a Solution class with a main method that implements a static method findAvgPrice to calculate the average price of resorts based on category and rating criteria. The main method reads resort data from user input and prints the average price or a message if no matching resorts are found.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Create a class Resort with the below attributes:

resortId - int
resortName - String
Category - String
resortPrice - double
resortRating - double

Write getters, setters and parameterized constructor in the above mentioned


attribute sequence as required.

Create class Solution with the main method.

Implement two static methods - findAvgPrice in Solution class.

findAvgPrice method:
----------------------------------
This method will take two input parameters - array of Resort objects and a string
parameter.
The method will return the average of the prices from resort objects whose Category
matched with passed as parameter and rating
will greater than 4.
If no resort present found, then the method should return 0.

Note : All the searches should be case insensitive.

These above mentioned static methods should be called from the main method.

For findAvgPrice method - The main method should print the average price as it is
if the returned value is
greater than 0, or it should print "No such Resort found".

Before calling these static methods in main, use Scanner object to read the values
of four resort objects referring attributes
in the above mentioned attribute sequence. Next, read the value for category.

Input
----------
1004
ABC
3 star
5400.00
4.5
1001
DEF
5 star
4781.45
4.0
1002
GHI
3 star
6235.72
4.2
1008
JKL
2 star
7454.00
4.2
3 star
Output
----------
The average price of 3 star:5817

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy