Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program that creates a ProfessorRating class consisting of professor ID and three ratings. The three ratings are used to evaluate easiness, helpfulness,

Write a Java program that creates a ProfessorRating class consisting of professor ID and three ratings. The three ratings are used to evaluate easiness, helpfulness, and clarity. The value for each rating is in the range of 1 to 5, with 1 is the lowest and 5 is the highest.

Test this class in main() method by creating an instance of ProfessorRating, allow user to enter the value for each rating and display the overall rating.

Include appropriate constructors and getter/setter methods for each data member in ProfessorRating class. Do not allow the professor id to be changed after an object has been constructed.

Provide a method calcRating() to compute and return the overall rating average, and displayResult() method to display all ratings and the average rating formatted with no decimal points

Can someone help me with my assignment? I'm suppose to write a JAVA program for assignment below but stumbled upon a hiccup and need help. Here is the code that I have so far:

public class Brandon_Nguyen_A6 { class ProfessorRating {

private final int id; private int easiness; private int helpfulness; private int clarity;

public ProfessorRating(int id) { this.id = id; }

public int getEasiness() { return easiness; }

public void setEasiness(int easiness) { this.easiness = easiness; }

public int getHelpfulness() { return helpfulness; }

public void setHelpfulness(int helpfulness) { this.helpfulness = helpfulness; }

public int getClarity() { return clarity; }

public void setClarity(int clarity) { this.clarity = clarity; }

public int calcRating() { return (easiness + helpfulness + clarity) / 3; }

public void displayResult() { System.out.println("Id: " + id + ", easiness: " + easiness + ", clarity: " + clarity + ", helpfulness: " + helpfulness + ", Average rating: " + calcRating()); } }

class ProfessorRatingTest {

public static void main(String[] args) { ProfessorRating rating = new ProfessorRating(7); rating.setClarity(4); rating.setHelpfulness(3); rating.setEasiness(5); rating.displayResult(); } }

It refuses to run because at public static void main(String[] args) { netbeans says that it is an illegal static declaration in inner class Brandun_Nguyen_A6.ProfessorRatingTest modifier 'static' is only allowed in constant variable declarations and the line under it is a non-static variable that cannot be referenced from a static context. I can't seem to figure it out and could use the help.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Oracle Solaris 11 System Administration

Authors: Bill Calkins

1st Edition

0133007170, 9780133007176

More Books

Students also viewed these Databases questions

Question

What role(s) does your HR department take on?

Answered: 1 week ago