home / study / engineering / computer science / questions and answers / problem
ID: 3808572 • Letter: H
Question
home / study / engineering / computer science / questions and answers / problem 2 – “sutures: sutures are strands or ...
Question: Problem 2 – “Sutures: Sutures are strands or f...
Bookmark
Problem 2 – “Sutures: 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 to prevent contamination. The packages are sealed on a machine with a sealing die. For the sealing to be a success, the die must be maintained at an established temperature, and contact the package with a predetermined pressure for an established time period. This time period is called the dwell time. The acceptable ranges for these three conditions are as follows:
Temperature: 150-170° C
Pressure: 60-70 psi
Dwell Time: 2-2.5 sec
Write a C++ program that reads a data file (from disk) containing data on batches of rejected sutures, the data is shown below. Each line of the file contains a batch number, temperature, pressure and dwell time for a batch. As the Quality Control Engineer, you need to analyze the data and compute the percent of batches rejected due to temperature, percent rejected due to pressure and percent rejected due to dwell time. If a specific batch was rejected in more than one category, it should be counted in all of the applicable totals. Write the output to a file. This output file will have your team name or names, and the results in terms of percent of failures in each category, the total numbers in each category and the total number of batches rejected.
Your input file* contains the following data:
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 62.5 2.03
27832 147.8 65.6 2.12
27976 155.4 71.0 2.34
28061 162.7 57.9 2.61
28251 171.3 59.2 2.23
28347 164.8 65.0 2.45
28782 152.8 58.6 2.05
28788 167.2 67.3 1.89
29192 149.6 60.9 2.26
29227 172.0 67.8 2.33
29482 155.2 73.1 2.47
29522 148.5 72.1 2.27
29617 168.3 49.7 2.63
29785 169.4 64.4 1.87
29885 146.6 55.9 2.42
29943 170.3 66.8 2.31
29957 166.3 56.8 2.11
29968 162.8 64.6 2.68
29987 149.2 69.7 2.22
Use infile and outfile
Please show full C++ source codes, screen print of output file and correct results using sutures input file .
For reading files: For writing files: ofstream outfile ifstream infile; infile open ("test.txt") outfile.open ("results.txt"); infile 1 outfile "Results: outfile yExplanation / Answer
#include<iostream>
#include<fstream>
using namespace std;
int main(){
int index;
int count=1;
double temp,pressure,time;
ifstream infile;
ofstream outfile;
infile.open("test.txt");
outfile.open("result.txt");
while (!infile.eof()){
infile>>index>>temp>>pressure>>time;
if(temp>=150 && temp<=170 && pressure>=60 && pressure<=70 && time>=2.0 && time<=2.5){
outfile<<index<<" "<<temp<<" "<<pressure<<" "<<time<<endl;
}
}
infile.close();
outfile.close();
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.