#include #include #include #include #include #include #define MAXJOBS 50 using namespace std; //help message 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\ X (Johnson's rule with due dates, 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), times and due dates are integers."; //structures struct onestage { string name; float time; float due; }; struct twostage { string name; float s1; float s2; }; struct johnson2 { string name; float s1; float s2; float due; }; //functions int inputA(onestage [], int, char * []); void outputA(onestage [], int, char); void first(onestage [], int &, float &, float &, float &, float &, float &); void shortest(onestage [], int &, float &, float &, float &, float &, float &); void earliest(onestage [], int &, float &, float &, float &, float &, float &); void critical(onestage [], int &, float &, float &, float &, float &, float &); void slack(onestage [], int &, float &, float &, float &, float &, float &); void all(onestage [], int); void header(char); void PrintTitle(float, char, int); int inputJ(twostage [], char * []); int inputJ2(johnson2 [], char * []); void calculationJ(twostage [], int, int []); void calculationJ2(johnson2 [], int, int []); void displayJ(twostage [], int [], int); void displayJ2(johnson2 [], int [], int); int main(int argc, char * argv[]) { onestage job1[MAXJOBS]; twostage job2[MAXJOBS]; johnson2 jobs[MAXJOBS]; int n=0; char choice; int stages; //Check to see if there are four arguments if(argc != 4) {cout<0) {cout< job1[c+1].time) { tempTime=job1[c].time; job1[c].time=job1[c+1].time; job1[c+1].time=tempTime; tempName=job1[c].name; job1[c].name=job1[c+1].name; job1[c+1].name=tempName; tempDue=job1[c].due; job1[c].due=job1[c+1].due; job1[c+1].due=tempDue; swap=true; } } }while(swap); //Display information for each job for(int x=0; x0) {cout< job1[a+1].due) { tempTime=job1[a].time; job1[a].time=job1[a+1].time; job1[a+1].time=tempTime; tempName=job1[a].name; job1[a].name=job1[a+1].name; job1[a+1].name=tempName; tempDue=job1[a].due; job1[a].due=job1[a+1].due; job1[a+1].due=tempDue; swap=true; } } }while(swap); //Display information for each job for(int b=0; b0) {cout< cRatio[m+1]) { tempRatio=cRatio[m]; cRatio[m]=cRatio[m+1]; cRatio[m+1]=tempRatio; tempTime=job1[m].time; job1[m].time=job1[m+1].time; job1[m+1].time=tempTime; tempName=job1[m].name; job1[m].name=job1[m+1].name; job1[m+1].name=tempName; tempDue=job1[m].due; job1[m].due=job1[m+1].due; job1[m+1].due=tempDue; swap=true; } } }while(swap); //Display information for each job for(int b=0; b0) {cout< slack[a+1]) { tempSlack=slack[a]; slack[a]=slack[a+1]; slack[a+1]=tempSlack; tempTime=job1[a].time; job1[a].time=job1[a+1].time; job1[a+1].time=tempTime; tempName=job1[a].name; job1[a].name=job1[a+1].name; job1[a+1].name=tempName; tempDue=job1[a].due; job1[a].due=job1[a+1].due; job1[a+1].due=tempDue; swap=true; } } }while(swap); //Display information for each job for(int z=0; z0) {cout<highest) highest=stage1[h]; if(stage2[h]>highest) highest=stage2[h]; } do{ //Initialize smallest number in both stages to the first element smallest1=stage1[0]; smallest2=stage2[0]; //Find smallest in stage1 for(int x=0; xsmallest2) {for(int y=count-1; y>-1; y--) {if(arr[y]==-1) {arr[y]=location2; stage1[location2]=highest + 1; stage2[location2]=highest + 1; total++; break; } } } }while(totalend1[c]) begin2[c]=job2[arr[c-1]].s2+begin2[c-1]; else if((begin2[c-1]+job2[arr[c-1]].s2)highest) highest=stage1[h]; if(stage2[h]>highest) highest=stage2[h]; } do{ //Initialize smallest number in both stages to the first element smallest1=stage1[0]; smallest2=stage2[0]; //Find smallest in stage1 for(int x=0; xsmallest2) {for(int y=count-1; y>-1; y--) {if(arr[y]==-1) {arr[y]=location2; stage1[location2]= highest + 1; stage2[location2]= highest + 1; total++; break; } } } }while(totalend1[c]) begin2[c]=jobs[arr[c-1]].s2+begin2[c-1]; else if((begin2[c-1]+jobs[arr[c-1]].s2)0) {cout<