Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Sutures are strands or fibers used to sew living tissue together after an injury

ID: 3640296 • Letter: S

Question

Sutures are strands or fibers used to sew living tissue together after an injury or an
operation. Packages of sutures must be sealed carefully before they are shipped to hospitals so that contaminants cannot enter the packages. The object that seals the package is referred to as a sealing die. Generally, sealing dies are heated with an electric heater. For the sealing process to be a success, the sealing die is maintained at an established temperature and must contact the package with a predetermined pressure for an established time period. The period in which the sealing die contacts the package is called the dwell time. For this assignment assume that the acceptable
ranges of parameters for an acceptable seal are as follows:
Temperature: 150-170 degrees C
Pressure: 60-70 psi
Dwell Time: 2-2.5 sec
A data file named <suture.txt> (included with the assignment) contains information on
batches of sutures that have been rejected during a one week period. Each line in the data file contains the batch number, temperature, pressure, and dwell time for a rejected batch. The quality control engineer would like to analyze this information and needs a report file that shows the total number of rejected batches, the number and percent of the batches rejected due to temperature, the number and percent rejected due to pressure, and the number and percent rejected due to dwell time. It is possible that a specific batch may have been rejected for more than one reason, and it should be counted in all applicable totals and percentages. Write a program to compute and print these numbers and percentages to an output file named lastname_output.txt (where lastname is your last name). A sample report
file generated by this program is shown below when <suture.txt> was used as input file.


Sample Run
The following shows the contents of a sample output file generated by the program when <suture.txt> file is used as input file. Notice that the percentages don’t necessarily add up to 100% because some batches were rejected due to multiple reasons.

Total number of defective batches: 6
Defective batches due to temperature: 2 (33.33%)
Defective batches due to pressure: 3 (50%)
Defective batches due to dwell time: 3 (50%)


suture.txt data file:
24551 145.5 62.3 2.13
24582 153.7 63.0 2.52
26553 160.4 58.8 2.51
26613 159.5 58.9 2.02
26624 160.5 61.5 1.98
27725 170.9 59.3 2.03

Explanation / Answer

please rate - thanks

#include <stdio.h>
#include<string.h>
int main()
{
FILE *input;
FILE *output;
int batch, tcount=0,pcount=0,dcount=0,count=0,bad,tbad=0;
double temp,pressure,dwell;
output=fopen("lastname.txt","w");
input=fopen("suture.txt","r");
if(input == NULL)
{ printf("Unable to open input file ");
    system("pause");
    return 0;
}

while(fscanf(input,"%d",&batch)>0)
    {count++;
     fscanf(input,"%lf",&temp);
     fscanf(input,"%lf",&pressure);
     fscanf(input,"%lf",&dwell);
     bad=0;
     if(temp<150||temp>170)
         {tcount++;
         tbad++;
         bad++;
         }
     if(pressure<60||pressure>70)
         {pcount++;
         if(bad==0)
             {tbad++;
             bad++;
             }
         }
     if(dwell<2||dwell>2.5)
         {dcount++;
         if(bad==0)
             {tbad++;
             bad++;
             }
          }
      }
fclose(input);
fprintf(output,"Total number of defective batches: %d ",tbad);
fprintf(output,"Defective batches due to temperature: %d (%.2f%%) ",tcount,(double)tcount/count*100.);
fprintf(output,"Defective batches due to pressure: %d (%.2f%%) ",pcount,(double)pcount/count*100.);
fprintf(output,"Defective batches due to dwell time: %d (%.2f%%) ",dcount,(double)dcount/count*100.);
fclose(output);
getch();
return 0;       
}