Explanation of Solution
a.
Method heading for each method:
- • Method heading for read rating from user is “public void readRating()”.
- • Method heading for gets maximum rating is “public int getMaximumRating()”...
Explanation of Solution
b.
Preconditions and postconditions of each method:
- • Precondition and postcondition of “public void readRating()” method.
- ○ Precondition: Display maximum rating range for given description using object of “RatingScore” class.
- ○ Postcondition: The “the_rating” is assigned to “value”.
- • Precondition and postcondition of “getMaximumRating()” method.
- ○ Precondition: None...
Explanation of Solution
c.
Test class for some Java statement:
//Create object "movieScore" from "RatingScore" class
RatingScore movieScore = new RatingScore();
//Create object "restaurantScore" from "RatingScore" class
RatingScore restaurantScore = new RatingScore();
//Call "setRatingScore" method for object "movieScore"
movieScore.setRatingScore("Merry's excellent movie", 8);
//Call "setRatingScore" method for object "restaurantScore"
restaurantScore.setRatingScore("Food quality", 20);
//Read rating for object "movieScore" by calling the method "readRating".
movieScore.readRating();
//Display the given statement
System...
Explanation of Solution
d.
Implementation of class:
RatingScore.java:
//Import package
import java.util.Scanner;
//Define a class "RatingScore"
public class RatingScore
{
//Declare required instance variable
private String desc;
private int maximum_rating;
private int the_rating;
//Set values to "RatingScore" attributes
public void setRatingScore(String d, int m)
{
desc = d;
maximum_rating = m;
the_rating = -1;
}
//Method definition for read rating from user
public void readRating()
{
//Display given statement for description
System.out.println("Enter rating for " + desc + ":");
//Display given maximum rating
System.out.println("Please enter an integer from 0 to " + maximum_rating);
//Create object for Scanner class
Scanner r = new Scanner(System.in);
//Assign "value" to "-1"
int value = -1;
//Assign required rating to "true"
boolean requiredRating = true;
//Check rating condition using "while" loop
while(requiredRating)
{
//Read input from user
value = r.nextInt();
if(value >= 0 && value <= maximum_rating)
{
requiredRating = false;
}
else
{
System.out.println("Error: The given rating is out of range.");
System.out.println("Enter an integer from 0 to " + maximum_rating);
}
}
the_rating = value;
}
//Method definition for gets maximum rating
public int getMaximumRating()
{
//Returns maximum rating
return maximum_rating;
}
//Method definition for gets rating
public int getRatingValue()
{
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
- 4. def modify_data(x, my_list): X = X + 1 my_list.append(x) print(f"Inside the function: x = {x}, my_list = {my_list}") num = 5 numbers = [1, 2, 3] modify_data(num, numbers) print(f"Outside the function: num = {num}, my_list = {numbers}") Classe Classe that lin Thus, A pro is ref inter Ever dict The The output: Inside the function:? Outside the function:?arrow_forwardpython Tasks 5 • Task 1: Building a Library Management system. Write a Book class and a function to filter books by publication year. • Task 2: Create a Person class with name and age attributes, and calculate the average age of a list of people Task 3: Building a Movie Collection system. Each movie has a title, a genre, and a rating. Write a function to filter movies based on a minimum rating. ⚫ Task 4: Find Young Animals. Create an Animal class with name, species, and age attributes, and track the animals' ages to know which ones are still young. • Task 5(homework): In a store's inventory system, you want to apply discounts to products and filter those with prices above a specified amount. 27/04/1446arrow_forwardOf the five primary components of an information system (hardware, software, data, people, process), which do you think is the most important to the success of a business organization? Part A - Define each primary component of the information system. Part B - Include your perspective on why your selection is most important. Part C - Provide an example from your personal experience to support your answer.arrow_forward
- Management Information Systemsarrow_forwardQ2/find the transfer function C/R for the system shown in the figure Re དarrow_forwardPlease original work select a topic related to architectures or infrastructures (Data Lakehouse Architecture). Discussing how you would implement your chosen topic in a data warehouse project Please cite in text references and add weblinksarrow_forward
- Please original work What topic would be related to architectures or infrastructures. How you would implement your chosen topic in a data warehouse project. Please cite in text references and add weblinksarrow_forwardWhat is cloud computing and why do we use it? Give one of your friends with your answer.arrow_forwardWhat are triggers and how do you invoke them on demand? Give one reference with your answer.arrow_forward
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning