You are asked to design and write a PSEUDOCODE that determines if a teacher is e
ID: 3726881 • Letter: Y
Question
You are asked to design and write a PSEUDOCODE 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
Design:
Create a structure teacher which contains the following details
struct teacher{
string name; //To store name
string dept; //To store department name
int yrs; //To store Years in Teaching Field
int degree; //To store degree in teaching field. integers are mapped to each degree 1 - Bachelor’s, 2 - Master’s, 3 - Doctarate
int credithrs; //credit hours in teaching field
int cyrs; //years in current rank
int rank; //current rank Integers mapped to rank. 1 - I, 2 - AS, 3 - AC, 4 - FP
};
Pseudo-code:
Basically, we iterate over all the teachers and check if they can upgrade according to the conditions give.
main(){
string str,name,dept,degree,rank;
int yrs,credithrs,cyrs,dg,errr=0,rnk;
int upast=0,upass=0,prof=0,neg=0,yrsneg=0;
take input
while(input.eof()==0){
input>>name>>dept>>yrs>>degree>>credithrs>>cyrs>>rank;
if(degree.compare("B")==0) dg = 1;
else if(degree.compare("M")==0) dg = 2;
else if(degree.compare("D")==0) dg =3;
if(rank.compare("I")==0) rnk = 1;
else if(rank.compare("AS")==0) rnk =2;
else if(rank.compare("AC")==0) rnk=3;
else if(rank.compare("FP")==0) rnk=4;
if(yrs>=5 && cyrs>=3){
if(dg==2 && rnk==1) upast+=1;
else if(dg==2 && rnk==2 && credithrs>=30) upass+=1;
else if(dg==3 && rnk==3) prof+=1;
else {neg++; yrsneg+=cyrs;}
}else{
neg++;
yrsneg+=cyrs;
}
insert into the structure..
}
input.close();
print("Total teachers eligible for Assistant Professor rank:: "+upast)
print("Total teachers eligible for Associate Professor rank:: "+upass)
pint("Total teachers eligible for Full Professor rank:: "+prof)
print(Total teachers not eligible for promotion:: "+neg)
print("Average number of years in current rank of teachers not eligible for promotion:: "+yrsneg/neg)
}
//Complete code in cpp
#include <bits/stdc++.h>
using namespace std;
struct teacher{
string name;
string dept;
int yrs;
int degree;
int credithrs;
int cyrs;
int rank;
struct teacher *next;
};
#define tch struct teacher
tch *teachers;
void insert(string name,string dept,int degree,int rank,
int yrs,int credithrs,int cyrs){
tch *temp;
temp = (tch*)malloc(sizeof(tch));
temp->name = name;
temp->dept = dept;
temp->yrs = yrs;
temp->degree = degree;
temp->rank = rank;
temp->credithrs = credithrs;
temp->cyrs = cyrs;
temp->next=teachers;
teachers = temp;
return;
}
int main(int argc, char *argv[]){
string str,name,dept,degree,rank;
int yrs,credithrs,cyrs,dg,errr=0,rnk;
int upast=0,upass=0,prof=0,neg=0,yrsneg=0;
ifstream input;
teachers = NULL;
//open the file which is given as command line argument
input.open(argv[1]);
if(input.fail()){
cout<<"Failed to open the file"<<endl;
return 0;
}
while(input.eof()==0){
input>>name>>dept>>yrs>>degree>>credithrs>>cyrs>>rank;
cout<<name<<" "<<dept<<" "<<yrs<<" "<<degree<<" "<<credithrs<<" "<<cyrs<<" "<<rank<<endl;
if(degree.compare("B")==0) dg = 1;
else if(degree.compare("M")==0) dg = 2;
else if(degree.compare("D")==0) dg =3;
else {errr = 1; cout<<"error in degree at name "<<name<<endl;}
if(rank.compare("I")==0) rnk = 1;
else if(rank.compare("AS")==0) rnk =2;
else if(rank.compare("AC")==0) rnk=3;
else if(rank.compare("FP")==0) rnk=4;
else {errr = 1; cout<<"error in rank at name "<<name<<endl;}
if(yrs<0) {errr = 1; cout<<"error in years working at name "<<name<<endl;}
if(cyrs<0) {errr = 1; cout<<"error in current workin years at name "<<name<<endl;}
if(credithrs<0) {errr = 1; cout<<"error in credit hours at name "<<name<<endl;}
cout<<dg<<" "<<rnk<<" "<<yrs<<" "<<cyrs<<" "<<credithrs<<endl;
if(errr==0){
if(yrs>=5 && cyrs>=3){
if(dg==2 && rnk==1) upast+=1;
else if(dg==2 && rnk==2 && credithrs>=30) upass+=1;
else if(dg==3 && rnk==3) prof+=1;
else {neg++; yrsneg+=cyrs;}
}else{
neg++;
yrsneg+=cyrs;
}
insert(name,dept,dg,rnk,yrs,credithrs,cyrs);
}
}
input.close();
if(errr==1){
cout<<"Input the values correctly"<<endl;
return 0;
}
cout<<"Total teachers eligible for Assistant Professor rank:: "<<upast<<endl;
cout<<"Total teachers eligible for Associate Professor rank:: "<<upass<<endl;
cout<<"Total teachers eligible for Full Professor rank:: "<<prof<<endl;
cout<<"Total teachers not eligible for promotion:: "<<neg<<endl;
cout<<"Average number of years in current rank of teachers not eligible for promotion:: "<<(double)yrsneg/(double)neg<<endl;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.