Question

Write a program that utilizes a Professor class. A professor has a first name, last name,...

Write a program that utilizes a Professor class. A professor has a first name, last name, affiliation, easiness grade, and a helpfulness grade. Grades range from 1 (lowest) to 5 (highest). The Professor class has two constructors. The first constructor initiates the object with just the first name, the last name, and the affiliation. The default value for easiness and helpfulness grade is 3. The second constructor initiates the object using the first name, the last name, the affiliation, and two grades.

The Professor class must not allow a first name or last name to be changed after instantiation.

The affiliation should be implemented as a property.

The grades should have both an accessor method and a mutator method. The Professor class should have a display method that prints all member variables in an appropriate format. For example, you can print out the first name, the last name, affiliation, and the two grades from the display method.

The Professor class should have a ToString() method. Make sure to override the ToString() method to present something meaningful.

Lastly, you should use the Main() method to demonstrate how the Professor class works. For example, create an instance of the Professor class with one of its two constructors. And then, invoke the display method on the instance.

Were using Visual Studios C# console.

I am stuck on how to get started and begin this program.

Homework Answers

Answer #1


public class Professor{

String FirstName;
String LastName;
String affiliation;
int EasinessGrade=3;
int HelpfullnessGrade=3;
  
Professor(String FName, String LName, String aff){
this.FirstName=FName;
this.LatNAme=LName;
this.affiliation=aff;
}
  
Professor(String FName, String LName, String aff, int EGrade, int HGrade){
this.FirstName=FName;
this.LastName=LName;
this.affiliation=getAff(aff);
  
setEasyGrade(EGrade);
this.EasinessGrade=getEasyGrade();
  
setHelpGrade(HGrade);
this.HelpfullnessGrade=getHelpGrade();
}
public String getAff(aff){
return aff;
}
  
public void setEasyGrade(EGrade){
this.EasinessGrade=EGrade;
}
public int getEasyGrade(){
return EasinessGrade;
}

public void setHelpGrade(HGrade){
this.HelpfullnessGrade=HGrade;
}
public int getHelpGrade(){
return HelpfullnessGrade;
}
  
public void display(){
System.out.println("First Name : "+FirstName);
System.out.println("Last Name : "+LastName);
System.out.println("Affiliation : "+affiliation);
System.out.println("EasinessGrade : "+EasinessGrade);
System.out.println("HelpfullnessGrade : "+HelpfullnessGrade);
}
  
  
public static void main(String []args){
  
Professor p=new Professor("Manan","Arora","Assistant Professor",5,5);
p.display();
}
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
The following is for a Java Program Create UML Class Diagram for these 4 java classes....
The following is for a Java Program Create UML Class Diagram for these 4 java classes. The diagram should include: 1) All instance variables, including type and access specifier (+, -); 2) All methods, including parameter list, return type and access specifier (+, -); 3) Include Generalization and Aggregation where appropriate. Java Classes description: 1. User Class 1.1 Subclass of Account class. 1.2 Instance variables __ 1.2.1 username – String __ 1.2.2 fullName – String __ 1.2.3 deptCode – int...
Design a class with the following requirements: 1- give the class a name from your choice....
Design a class with the following requirements: 1- give the class a name from your choice. 2- write some code that creates three instance variables, choose a name and type for each one of them. (must have two private and one public variables) 3- Initialize the variables using two different constructors. 4- Use mutator and accessor methods (set and get) for the private data members. 5- Display the value of each member variable using a method. 6- In the main,...
Design a class with the following requirements: 1- give the class a name from your choice....
Design a class with the following requirements: 1- give the class a name from your choice. 2- write some code that creates three instance variables, choose a name and type for each one of them. (must have two private and one public variables) 3- Initialize the variables using two different constructors. 4- Use mutator and accessor methods (set and get) for the private data members. 5- Display the value of each member variable using a method. 6- In the main,...
Has to be written in C#! Write a program that includes an Employee class that can...
Has to be written in C#! Write a program that includes an Employee class that can be used to calculate and print the take-home pay for a commissioned sales employee. Items to include as data members are employee number, first name, last name, and total sales. All employees receive 9% of the total sales of the month. Federal tax rate is 18%. Retirement contribution is 10%. Social Security tax rate is 6%. Use appropriate constants, design an object-oriented solution, and...
1. Circle: Implement a Java class with the name Circle. It should be in the package...
1. Circle: Implement a Java class with the name Circle. It should be in the package edu.gcccd.csis. The class has two private instance variables: radius (of the type double) and color (of the type String). The class also has a private static variable: numOfCircles (of the type long) which at all times will keep track of the number of Circle objects that were instantiated. Construction: A constructor that constructs a circle with the given color and sets the radius to...
(Use JAVA) For this program, you need to create three classes, one of which is a...
(Use JAVA) For this program, you need to create three classes, one of which is a main class that includes aggregation from the other two classes. Each of the classes must include at least two fields, multiple constructors, accessor and mutator methods, and toString. Methods in your main class must include: 1. .equals 2. .copy 3. One that passes an object other than the .copy method 4. One that returns an object 5. toString that calls the toStrings from the...
Create a class called Employee that contains three instance variables (First Name (String), Last Name (String),...
Create a class called Employee that contains three instance variables (First Name (String), Last Name (String), Monthly Salary (double)). Create a constructor that initializes these variables. Define set and get methods for each variable. If the monthly salary is not positive, do not set the salary. Create a separate test class called EmployeeTest that will use the Employee class. By running this class, create two employees (Employee object) and print the annual salary of each employee (object). Then set the...
Write the program in java Implement a class Product. Create instance variables to store product name...
Write the program in java Implement a class Product. Create instance variables to store product name and price and supply the values through constructor. For example new Product(“Toaster’, 29.95). Create methods, getName, getPrice. Write a method productPrinter that prints the product name and its price after reducing it by $5. Create a main class and necessary constructs in the main class to run the Product class.
Consider the following incomplete declaration of a Name class for 2a-2c. public class Name something missing...
Consider the following incomplete declaration of a Name class for 2a-2c. public class Name something missing {    private String first;    private String last;    public Name(String firstName, String lastName)    { first = firstName; last = lastName;    }    //additional methods } 2a) In the first two parts, you will modify the Name class so that it implements the Comparable interface. Show here what should go in place of something missing in the first line of the...
IN JAVA Inheritance Using super in the constructor Using super in the method Method overriding Write...
IN JAVA Inheritance Using super in the constructor Using super in the method Method overriding Write an application with five classes Vehicle, Car, Bus, Truck, and Tester class with main method in it. The following characteristics should be used: make, weight, height, length, maxSpeed, numberDoors, maxPassenges, isConvertable, numberSeats, maxWeightLoad, and numberAxels. Characteristics that are applicable to all vehicles should be instance variables in the Vehicle class. The others should be in the class(s) where they belong. Class vehicle should have...