#include #include #include #include using namespace std; static char *help = "jseq stages rule inputfile \n\ stages = 1 or 2, the number of work centers or process stages\n\ rule = job sequencing rule:\n\ F (first-come, first served, 1-stage)\n\ S (shortest processing time first, 1-stage)\n\ E (earliest due date, 1-stage)\n\ C (critical ratio, 1-stage)\n\ R (slack time remaining, 1-stage)\n\ A all rules for 1-stage problem\n\ J (Johnson's rule, 2-stage)\n\ P (Palmer's method, multi-stage)\n\ file = name of text input file, one job per line, in form:\n\ jobname processTime dueDate (1-stage problems)\n\ jobname stage1time stage2time (2-stage problems)\n\ jobnames are 1-8 characters (no blanks), integer times and due dates."; //functions float input(char [], float [], float[], float, char* []); void output(char [], float [], float [], float, char); void header(char); void first(char [], float [], float [], float &, float &, float &, float &, float &, float &); void shortest(char [], float [], float [], float &, float &, float &, float &, float &, float &); void earliest(char [], float [], float [], float &, float &, float &, float &, float &, float &); void critical(char [], float [], float [], float &, float &, float &, float &, float &, float &); void slack(char [], float [], float [], float &, float &, float &, float &, float &, float &); //main module int main(int argc, char *argv[]) { char name[50]; float time[50]; float due[50]; float n; char choice; int stages; //Check to see if there are four arguments if (argc != 4) {cout<> n[0]; infile >> t[0]; infile >> d[0]; int x=0; //Get the rest of the data from file while(!infile.eof()) { x++; infile >> n[x]; infile >> t[x]; infile >> d[x]; //Keep track of how many jobs are in the file count++; } //Close the file and return count infile.close(); return count; } //Output function void output(char name[], float time[], float due[], float n, char choice) { float flow=0; float tardy=0; float totalflow=0; float totaltardy=0; float numtardy=0; //Call job function according to choice if(toupper(choice)=='F') first(name, time, due, n, flow, tardy, totalflow, totaltardy, numtardy); else if(toupper(choice)=='S') shortest(name, time, due, n, flow, tardy, totalflow, totaltardy, numtardy); else if(toupper(choice)=='E') earliest(name, time, due, n, flow, tardy, totalflow, totaltardy, numtardy); else if(toupper(choice)=='C') critical(name, time, due, n, flow, tardy, totalflow, totaltardy, numtardy); else if(toupper(choice)=='R') slack(name, time, due, n, flow, tardy, totalflow, totaltardy, numtardy); cout<<"--- ---- ---- ---- ---------"; if(toupper(choice)=='C') cout<<" -----"; else if(toupper(choice)=='R') cout<<" ---------"; cout<0) {cout< time[c+1]) { tempTime=time[c]; time[c]=time[c+1]; time[c+1]=tempTime; tempName=name[c]; name[c]=name[c+1]; name[c+1]=tempName; tempDue=due[c]; due[c]=due[c+1]; due[c+1]=tempDue; swap=true; } } }while(swap); //Display information for each job for(int x=0; x0) {cout< due [a+1]) { tempTime=time[a]; time[a]=time[a+1]; time[a+1]=tempTime; tempName=name[a]; name[a]=name[a+1]; name[a+1]=tempName; tempDue=due[a]; due[a]=due[a+1]; due[a+1]=tempDue; swap=true; } } }while(swap); //Display information for each job for(int b=0; b0) {cout<(count)]; float tempRatio; //Calculate CR for each job and store in cRatio for(int x=0; x cRatio[m+1]) { tempRatio=cRatio[m]; cRatio[m]=cRatio[m+1]; cRatio[m+1]=tempRatio; tempTime=time[m]; time[m]=time[m+1]; time[m+1]=tempTime; tempName=name[m]; name[m]=name[m+1]; name[m+1]=tempName; tempDue=due[m]; due[m]=due[m+1]; due[m+1]=tempDue; swap=true; } } }while(swap); //Display information for each job for(int b=0; b0) {cout<(count)]; float tempSlack; //Calculate slack time remaining for each job for(int n=0; n slack[a+1]) { tempSlack=slack[a]; slack[a]=slack[a+1]; slack[a+1]=tempSlack; tempTime=time[a]; time[a]=time[a+1]; time[a+1]=tempTime; tempName=name[a]; name[a]=name[a+1]; name[a+1]=tempName; tempDue=due[a]; due[a]=due[a+1]; due[a+1]=tempDue; swap=true; } } }while(swap); //Display information for each job for(int z=0; z0) {cout<