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 plus MyProgrammingLab with Pearson eText -- Access Card Package (7th Edition)
- EX:[AE00]=fa50h number of ones =1111 1010 0101 0000 Physical address=4AE00h=4000h*10h+AE00h Mov ax,4000 Mov ds,ax; DS=4000h mov ds,4000 X Mov ax,[AE00] ; ax=[ae00]=FA50h Mov cx,10; 16 bit in decimal Mov bl,0 *: Ror ax,1 Jnc ** Inc bl **:Dec cx Jnz * ;LSB⇒CF Cf=1 ; it jump when CF=0, will not jump when CF=1 HW1: rewrite the above example use another wayarrow_forwardEX2: Write a piece of assembly code that can count the number of ones in word stored at 4AE00harrow_forwardWrite a program that simulates a Magic 8 Ball, which is a fortune-telling toy that displays a random response to a yes or no question. In the student sample programs for this book, you will find a text file named 8_ball_responses.txt. The file contains 12 responses, such as “I don’t think so”, “Yes, of course!”, “I’m not sure”, and so forth. The program should read the responses from the file into a list. It should prompt the user to ask a question, then display one of the responses, randomly selected from the list. The program should repeat until the user is ready to quit. Contents of 8_ball_responses.txt: Yes, of course! Without a doubt, yes. You can count on it. For sure! Ask me later. I'm not sure. I can't tell you right now. I'll tell you after my nap. No way! I don't think so. Without a doubt, no. The answer is clearly NO. (You can access the Computer Science Portal at www.pearsonhighered.com/gaddis.)arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning