Question: Java please Problem Statement Back to skiing this week. You are going to build a program that manages ski ratings for a store. To do

Java please

Problem Statement

Back to skiing this week. You are going to build a program that manages ski ratings for a store. To do this, you need two classes. The Ski class will represent a ski and the Store class (partially provided) will represent a ski store. Customers will have the capability of rating a ski by giving it some integer number of stars. Suppose for some ski, one customer gave it 5 stars, another gave it 4 stars, and the final customer also gave it 4 stars, that ski would then have an average rating of 4.33 stars (don't worry about the number of digits after the decimal point). Your Ski class will have a variable for the ski's name and whatever data you need to track to determine the average "number of stars" it earned. You will also need a method called addCustReview in the Ski class that will take an integer parameter representing the number of stars the customer wishes to award that ski. After numerous customers review the ski, you will have the data you need to calculate the average rating, as demonstrated above.

Assignment

Create a project called Inlab4.

Copy this code into a class called Store and review it so you see what is going on.

* Write a description of class Store here.

*

=

* @version 03 Feb 17

*/

public class Store

{

private String name;

private Ski s1;

private Ski s2;

public Store(String inName, Ski in1, Ski in2)

{

name = inName;

s1 = in1;

s2 = in2;

}

public double getAvgRating()

{

// fill in with your own code

}

public void printStats()

{

System.out.println(name + ":");

System.out.println(" Average Ski Rating: " + getAvgRating());

System.out.println(" Skis:");

s1.printStats();

s2.printStats();

}

}

Create a class called Ski, where the only input parameter to the constructor is the name of the Ski.

Create a method in the Ski class called addCustReview that will take the number of stars awarded for one customer review as the input parameter.

Create a method in the Ski class called printStats that will print out the name of the ski, its average rating, and the total number of reviews it received.

Complete the getAvgRating method in the Store class so that it gives the average rating of skis in the store as the total number of stars awarded for all skis in the store divided by the total number of reviews given for all skis in the store. Note: This is not the average of the average ski ratings. Draw out an example if you don't see the distinction.

Finally, build a Driver that creates two Ski instances, adds some customer reviews, creates a store with those two skis, then calls printStats on the store. Make sure the output is correct.

Your output will vary depending on your formatting and specific reviews, but as a guide, here is my output.

Backcountry: Average Ski Rating: 4.285714285714286 Skis: Voile V8 -> average of 4.75 stars out of 4 reviews. DPS Wailer 112 -> average of 3.6666666666666665 stars out of 3 reviews. 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!