You are asked to design and write a JAVA Program that determines if a teacher is
ID: 3732484 • Letter: Y
Question
You are asked to design and write a JAVA Program that determines if a teacher is eligible for promotion. To be eligible for promotion, teachers at Franzia College must have taught in the teaching field for at least 5 years. In addition to the number of year in the teaching field, teachers must meet the requirements shown below to move from their current rank to the next rank: (Only four ranks exist at Franzia College.) Rank Requirements Instructor Bachelor’s degree in teaching field Assistant Professor Current rank = Instructor and Master’s degree in teaching field Associate Professor Current rank = Assistant Professor, Master’s degree in teaching field, plus 30 credit hours in Teaching field Full Professor Current rank = Associate Professor and Doctorate degree In addition, no teacher is eligible for promotion if he/she has not served at least three years in his/her current rank. The rank below Assistant Professor is Instructor. Teachers can only move up one rank at a time. The input record contains: Name Department Name Years in Teaching Field Type of Degree in teaching field (B, M or D) B = Bachelor’s M = Master’s D = Doctorate Credit Hours in Teaching Field Years in Current Rank Current Rank (I, AS, AC, or FP) I = Instructor AS = Assistant Professor AC = Associate Professor FP = Full Professor The output will consist of: Total teachers eligible for Assistant Professor rank Total teachers eligible for Associate Professor rank Total teachers eligible for Full Professor rank Total teachers not eligible for promotion Average number of years in current rank of teachers not eligible for promotion Write the program to process any number of teachers. Validate the input for the years in teaching field, credit hours in teaching field and years in current rank (values must be greater than 0). Validate the input for the type of degree (must be B, M or D) and validate the input for the current rank (must be I, AS, AC or FP) MUST HAVE THE CORRECT LOOP!
Explanation / Answer
here is your program : ------------>>>>>>>>
Teacher.java: ---------->>>>>>>>
public class Teacher{
private String name;
private String dName;
private char degree;
private int year;
private int creditH;
private String currentRank;
public Teacher(String n,String dn,char deg,int y,String cR,int crH){
name = n;
dName = dn;
degree = deg;
year = y;
currentRank = cR;
creditH = crH;
}
public int getCreditHours(){
return creditH;
}
public String getName(){
return name;
}
public String getDepartmentName(){
return dName;
}
public String getCurrentRank(){
return currentRank;
}
public char getDegree(){
return degree;
}
public int getYear(){
return year;
}
}
TeacherMain.java : ----------->>>>>>>>>>
import java.util.ArrayList;
import java.util.Scanner;
public class TeacherMain{
public static void calculate(ArrayList<Teacher> teachers){
int AS = 0,AC = 0, FP = 0;
int NA = 0;
int totalYear = 0;
Teacher temp = null;
for(int i = 0;i<teachers.size();i++){
temp = teachers.get(i);
if(temp.getYear() >= 3){
if(temp.getCurrentRank().equals("I") && (temp.getDegree() == 'M' || temp.getDegree() == 'D')){
AS++;
}
else if(temp.getCurrentRank().equals("AS") && (temp.getDegree() == 'M' || temp.getDegree() == 'D') && temp.getCreditHours() > 30){
AC++;
}
else if(temp.getCurrentRank().equals("AC") && temp.getDegree() == 'D'){
FP++;
}else{
NA++;
totalYear = totalYear + temp.getYear();
}
}else{
NA++;
totalYear = totalYear + temp.getYear();
}
}
System.out.println("Total Eligible for Assistant Professor = "+AS);
System.out.println("Total Eligible for Associate Professor = "+AC);
System.out.println("Total Eligible for Full Professor = "+FP);
System.out.println("Total Not Eligible "+NA);
if(NA != 0)
System.out.println("Avarage Year of Not Elligible "+(totalYear/NA));
else
System.out.println("Avarage Year of Not Elligible 0 ");
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<Teacher> teachers = new ArrayList<>();
Teacher temp = null;
String ch = "yes";
String n = "";
String dn = "";
String cur = "s";
int y = 0;
int crh = 0;
char g = ' ';
while(ch.equals("yes")){
System.out.println(" Enter the Name : ");
n = sc.next();
System.out.println(" Enter the Department Name : ");
dn = sc.next();
while(true){
System.out.println(" Enter the current rank : ");
cur = sc.next();
if(cur.equals("I") || cur.equals("AS") || cur.equals("AC") || cur.equals("FP")){
break;
}
System.out.println("Please Enter ("I","AS","AC","FP"): ");
}
while(true){
System.out.println(" Enter the credit Hours : ");
crh = sc.nextInt();
if(crh > 0){
break;
}
System.out.println("Please Enter Integer graeter than 0");
}
while(true){
System.out.println(" Enter the grade : ");
g = sc.next().charAt(0);
if(g == 'B' || g == 'M' || g == 'D'){
break;
}
System.out.println("Please Enter ("B","M","D"): ");
}
while(true){
System.out.println(" Enter the year in current rank : ");
y = sc.nextInt();
if(y > 0){
break;
}
System.out.println("Please Enter Integer Greater than 0");
}
temp = new Teacher(n,dn,g,y,cur,crh);
teachers.add(temp);
System.out.println("Do you have More Entry (yes,no) ? ");
ch = sc.next();
}
calculate(teachers);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.