Java Program** Each year the legislature of a state rates the productivity of th
ID: 3738571 • Letter: J
Question
Java Program**
Each year the legislature of a state rates the productivity of the faculty of each of the state-supported colleges and universities. The rating is based on reports submitted by each faculty member indicating the average number of hours worked per week during the school year. Each faculty member is ranked, and the university also receives an overall rank. The faculty productivity rank is computed as follows:
(1) Faculty members averaging over 55 hours per week are considered highly productive.
(2) Faculty members averaging between 35 and 55 hours a week, inclusive, are considered satisfactory.
(3) Faculty members averaging fewer than 35 hours a week are considered overpaid.
The productivity rating of each school is determined by first computing the faculty average for the school and then comparing the faculty average to the category ranges above. Write a program to rank the following faculty:
Your program should print a three-column table giving the name, hours and productivity rank of each faculty member. It should also compute and print the school's overall productivity ranking.
Your program must use function(s) and must be Object Oriented. Your function(s) must use arguments.
Name HERM FLO JAKE MO SOL TONY AL Hours 63 37 20 72 4 0 12Explanation / Answer
FacultyMembers.txt
HERM 63
FLO 37
JAKE 20
MO 55
SOL 72
TONY 40
AL 12
________________
Faculty.java
public class Faculty {
//Declaring instance variables
private String name;
private int hours;
//Parameterized constructor
public Faculty(String name, int hours) {
super();
this.name = name;
this.hours = hours;
}
//getters and setters
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getHours() {
return hours;
}
public void setHours(int hours) {
this.hours = hours;
}
//This Method will return the Productivity rating
public String getProductivityRating(int hours)
{
String str="";
if(hours>55)
str="highly productive";
else if(hours>=35 && hours<=55)
str="satisfactory";
else if(hours<35)
str="overpaid";
return str;
}
}
__________________
Test.java
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
//Declaring variables
String name;
int hrs, tot = 0,count=0;
Scanner sc = null;
Faculty f=null;
try {
//Opening the file
sc = new Scanner(new File("FacultyMembers.txt"));
System.out.println("Name Hours Productivity Rating");
System.out.println("---- ----- ---------------");
//reading the data from the file
while (sc.hasNext()) {
name = sc.next();
hrs = sc.nextInt();
count++;
f=new Faculty(name, hrs);
System.out.println(f.getName()+" "+f.getHours()+" "+f.getProductivityRating(hrs));
}
System.out.println("Overall School Productivity Ranking :"+f.getProductivityRating((int)(tot)/count));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
sc.close();
}
}
__________________
Output:
Name Hours Productivity Rating
---- ----- ---------------
HERM 63 highly productive
FLO 37 satisfactory
JAKE 20 overpaid
MO 55 satisfactory
SOL 72 highly productive
TONY 40 satisfactory
AL 12 overpaid
Overall School Productivity Ranking :overpaid
________________Thank You
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.