Explanation of Solution
a.
Method heading for each method:
- Method heading for project rating is “public void rateProject()”.
- Method heading for total rating is “public int totalRating()”...
Explanation of Solution
b.
Preconditions and postconditions of each method:
- Precondition and postcondition of “public void rateProject()” method.
- Precondition: None.
- Postcondition: Ratings were attained from user for each category and then assign it to the variable.
- Precondition and postcondition of “totalRating()” method.
- Precondition: None.
- Postcondition: This method returns total rating for each category...
Explanation of Solution
c.
Java statement for testing the class:
//Create an object for "ScienceFairProjectRating" class
ScienceFairProjectRating joesProject = new ScienceFairProjectRating();
ScienceFairProjectRating suesProject = new ScienceFairProjectRating();
//Call "initialize()" method to initialize the variables
joesProject.initialize("Weather and You", "U1256", "Joe Minnow");
suesProject...
Explanation of Solution
d.
Implementation of class:
ScienceFairProjectRating.java:
//Import the java package
import java.util.Scanner;
//Define the class
public class ScienceFairProjectRating
{
//Declare the required variables
private String projectName;
private String identifier;
private String submitter;
//Create an object for "RatingScore" class
private RatingScore creativeRating;
private RatingScore thoughtRating;
private RatingScore thoroughnessRating;
private RatingScore technicalRating;
private RatingScore clarityRating;
//Define the "initialize()" method
public void initialize(String name, String id, String person)
{
//Initialize the required variables
projectName = name;
identifier = id;
submitter = person;
creativeRating = new RatingScore();
thoughtRating = new RatingScore();
thoroughnessRating = new RatingScore();
technicalRating = new RatingScore();
clarityRating = new RatingScore();
creativeRating.initialize("How creative was this project", 30);
thoughtRating.initialize("Was scientific thought displayed in the project", 30);
thoroughnessRating.initialize("Did the project cover the material thoroughly", 15);
technicalRating.initialize("Were appropriate technical skill displayed", 15);
clarityRating.initialize("Was the presentation of the project clear", 10);
}
//Define the "rateProject()" method
public void rateProject()
{
//Display the message to get the rating
System.out.println("Please enter ratings for the project " + projectName + "(" + identifier + ")");
/*Call "inputRating()" method using objects of RatingScore class. */
creativeRating.inputRating();
thoughtRating.inputRating();
thoroughnessRating.inputRating();
technicalRating.inputRating();
clarityRating.inputRating();
}
//Define the "totalRating()" method
public int totalRating()
{
//Calculate the total rating and then return it
return creativeRating.getRating() + thoughtRating.getRating() + thoroughnessRating.getRating() + technicalRating.getRating() + clarityRating.getRating();
}
//Define the "maxRating()" method
public int maxRating()
{
//Calculate the maximum rating and then return it
return creativeRating.getMaxRating() + thoughtRating.getMaxRating() + thoroughnessRating.getMaxRating() + technicalRating.getMaxRating() + clarityRating.getMaxRating();
}
//Define the "getRatingString()" method
public String getRatingString()
{
//Calculate the project rating and then return it
return "Project " + projectName + "(" + identifier + ") by " + submitter + " was given the score "
+ totalRating() + "/" + maxRating();
}
//Define the "main()" method
public static void main(String[] args)
{
/*Create an object for "ScienceFairProjectRating" class. */
ScienceFairProjectRating joesProject = new ScienceFairProjectRating();
ScienceFairProjectRating suesProject = new ScienceFairProjectRating();
/*Call initialize() method to initialize the variables. */
joesProject.initialize("Weather and You", "U1256", "Joe Minnow");
suesProject.initialize("Hot Air", "U1275", "Susan Shark");
//Call "ratePorject()" to rate the project
joesProject.rateProject();
suesProject.rateProject();
System.out.println("Judging is completed: ");
/*Call "getRatingString()" method to get the project rating. */
System.out.println(joesProject.getRatingString());
System.out.println(suesProject.getRatingString());
}
}
RatingScore.java:
//Import the java package
import java.util.Scanner;
//Define the class
public class RatingScore
{
//Declare the required variables
private String description;
private int maximumRating;
private int theRating;
//Define the "initialize()" method
public void initialize(String desc, int max)
{
//Initialize the required variables
description = desc;
maximumRating = max;
theRating = -1;
}
//Define "inputRating()" method
public void inputRating()
{
//Read the maximum rating value from user
System...
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
- Write the Java program bellow: add a new HourlyEmployee class to this project, so that it makes the main function work as shown in the sample output. Specifically you will need: To define HourlyEmployee as a sub-class of Employee (so it extends Employee). Two additional instance variables: an hourlyRate (dollars/hour) and an expectedHoursPerWeek. Both of these should have datatype double. A constructor that has all instance variables as parameters An input() function that overrides and uses its super-class input function, also inputting the two variables above. A weeksPay() method that returns the expectedHoursPerWeek times hourlyRate. An accessor (getter) and mutator (setter) for expectedHoursPerWeek An output() method that overrides and uses its super-class output function, also outputting the expected hours per week. Code: import java.util.Scanner; import java.util.ArrayList; class Main { publicstaticvoid main(String[] args) { Scanner scan = new Scanner(System.in); int i;…arrow_forwardthe Java program bellow is not completed. add a new HourlyEmployee class to this project, so that it makes the main function work as shown in the sample output. Specifically you will need: To define HourlyEmployee as a sub-class of Employee (so it extends Employee). Two additional instance variables: an hourlyRate (dollars/hour) and an expectedHoursPerWeek. Both of these should have datatype double. A constructor that has all instance variables as parameters An input() function that overrides and uses its super-class input function, also inputting the two variables above. A weeksPay() method that returns the expectedHoursPerWeek times hourlyRate. An accessor (getter) and mutator (setter) for expectedHoursPerWeek An output() method that overrides and uses its super-class output function, also outputting the expected hours per week. Code: import java.util.Scanner; import java.util.ArrayList; class Main { publicstaticvoid main(String[] args) { Scanner scan = new Scanner(System.in);…arrow_forwardImplement the design of the CSE and EEE classes that are derived from the Department class so that the following output is produced: Driver Code Output class Department: def __init__(self, s): self.semester = s self.name = "Default" self.id = -1 def student_info(self): print("Name:", self.name) print("ID:", self.id) def courses(self, c1, c2, c3): print("No courses Approved yet!") s1 = CSE("Rahim", 16101328,"Spring2016") s1.student_info() s1.courses("CSE110", "MAT110", "ENG101") print("==================") s2 = EEE("Tanzim", 18101326, "Spring2018") s2.student_info() s2.courses("Mat110", "PHY111", "ENG101") print("==================") s3 = CSE("Rudana", 18101326, "Fall2017") s3.student_info() s3.courses("CSE111", "PHY101", "MAT120") print("==================") s4 = EEE("Zainab", 19201623, "Summer2019") s4.student_info() s4.courses("EEE201", "PHY112", "MAT120") Name: Rahim ID: 16101328 Courses Approved to this CSE student in Spring2016 semester : CSE110 MAT110 ENG101 ==================…arrow_forward
- We already have the address and vehicle class for the system below. We will need a CarShow class with IsSanctioned() method, Owner class with IsOwner method and a main class that creates objects and implements all our existing classes. Use the class diagrams. Make sure to include respective attributes, setters, getters and constructors in your code Explain your code in a few words.arrow_forwardConsider the case of a shop that sells CDs in cash. The CDs are of three types: Movie CDs, Software CDs and Music CDs. For each of the following CD types, the required attributes are:Movie CD: Movie Title, Year of Release, Lead Actor Name, CD price and CD quantitySoftware CD: Software Name, Edition, Year of Release, CD price and CD quantityMusic CD: Album Title, Year of Release, Number of Songs, Format, CD price and CD quantity All objects of the classes cannot change their state once they are instantiated. How will you implement this?arrow_forwardConsider the above scenario, where Billing class has composition relationship with Doctor having private instance variables (docName, docID and docFee) and a public getDocID() method, Patient having private instance variables (pName, pID, pDisease), Medicine having private instance variables (medID, medName, medQty, medPrice), and MedicalTest having private instance variables (testID, testName, testPrice). In addition, each class shall have toString method to display its object state. Also define getDocInfo method in Billing class that shall return the doctor. Implement getPaymentAmount() method in Billing class that shall return the total billing amount that includes doctor fee, medicine cost and medical tests fee. Considering the above scenario, write code that shall perform the following in the driver/test class: Get an amount from user. Traverse the ArrayList<Billing> using enhanced for loop. Print the billing details of those bills having total billing amount greater or…arrow_forward
- For the 'The Chicken class' on the app intelliJ in java. The Chicken class must:• Define three fields called exactly name, pricePerKilo and inStock. The name field must be of type String, the pricePerKilo must be of type int (representing the cost per kilo in pence) and the inStock field must be of type boolean.• Initialise the three fields via a constructor that takes exactly two parameters. The first parameter must be of type String and the second parameter must be of type int. The first parameter must initialise the name field and the second must initialise the pricePerKilo field. The constructor must set the inStock field to true for all Chicken objects. There must be no parameter to the constructor for the inStock field.• Define getters for all three fields using the standard getter naming convention. In particular, note that the getter for the inStock field must be called getInStock rather than isInStock.• Define setters for the pricePerKilo and inStock fields using the standard…arrow_forwardIn this challenge, we'll implement an Account class along with two derived classes, Savings and Current. Problem Statement# Write a code that has: ● A parent class named Account. ○ Inside it define: ■ a protected double member balance ■ public void Withdraw(double amount) ■ public void Deposit(double amount) ■ public void printBalance() ● Then, there are two derived classes ○ Savings class ■ has a private member interestRate set to 0.8 ■ Withdraw(double amount) deducts amount from balance with interestRate ■ Deposit(double amount) adds amount in balance with interestRate ■ printBalance() displays the balance in the account ○ Current class ■ Withdraw(double amount) deducts amount from balance ■ Deposit(double amount) adds amount in balance ■ printBalance() displays the balance in the account Input# ● In the Savings class, balance is set to 50000 in the parametrized constructor ● In the Current class, balance is set to 50000 in the parametrized constructor Output# Balance before…arrow_forwardreate a Java Project (with a class and a test class) to represent some real-world entity such as a technology item (TV, Fan etc), an animal, a person, a vehicle, etc. In our class, we have already seen example classes such as Circle, Student, Rectangle, TV etc. The class will: a) Create a total of 5 member variables for the class by selecting the appropriate data types for each field. For example, a class to represent a lamp might include color, price, height, numBulbs, batteryOperated. Each of these 5 variables needs a data type. b) Includeatleastthreedifferentconstructormethods,includingthedefaultconstructor (no argument constructor), so totally three constructors. c) Create a member function showValues( ) to display the values of an object in a formatted manner. The Java test class (with a main method) will: a) Instantiate at least three objects (using each of the constructors at least once) with your program. b) Store the data from the individual objects into an array. c)…arrow_forward
- For a parking management system, use the Observer pattern to implement this interaction using Java and implement the three classes mentioned below. Implement a ParkingObserver that has the role of the Observer. The Observable classes (Subjects) will be the ParkingLots. It would be helpful if the notify method in the subjects (and update method in the observers) took a parameter, perhaps an object of type ParkingEvent, which could have fields including the lot, timeIn, timeOut (if relevant), and permit. The ParkingObserver should register with each ParkingLot and receive the messages. Once a car enters (in an entry-scan only lot) or leaves (in an entry-scan and exit-scan lot), then the ParkingObserver will be updated, and then can register the charge with the parking system via the TransactionManager’s park() method. Based on these requirements you should implement three actor classes in this interaction using java: TransactionManager, ParkingObserver and ParkingLot. 1. The…arrow_forwardWrite a program in the Java language requires the management of university students, where student data (name, student number, and specialization) are saved, and then he can add and delete study materials for the current semester, and you can also add the grade for each subject (with the addition of the final code for the degree automatically).Note: The class principle is used to solve this assignment.arrow_forwardWrite a full class that represents a Phone, described by a name, price, and then whether the phone comes enabled with Bluetooth. The default value is that most phones come enabled. Include instance data, one or more constructors, getters and setters, a toString, and an equals method. Required validation for the variables Implement the Comparable interface. Order phones based on name and then price. Show make the driver in a different class to test the methods using user-inputarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education