cis 210 Introduction to C++ Programming (Fall 2017) Assignment-4 Points: 100 Due
ID: 3818935 • Letter: C
Question
cis 210 Introduction to C++ Programming (Fall 2017) Assignment-4 Points: 100 Due Date: 4/17/2017 (beginning of class Specifications: (D. Etter and J. Ingber. "Engineering Problem solving with C++. Person, 2012 together after an injury or an 1. Sutures are strands or fibers used to sew living issue 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. 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 contracts the package is called the dwell time. Assume that the acceptable range of parameters for an acceptable seal are the following: Temperature: 150-170 degrees C (inclusive) Pressure: 60-70 psi (inclusive) Dwell time: 2-2.5 seconds (inclusive) A data file named suture.dat contains information on batches of sutures that have been rejected. Each line in the file contains the batch number, temperature, pressure, and dwell time for a rejected batch. Write a C++ program to analyze this data and output a report that contains the following information: Percent of batches rejected due to temperature Percent of batches rejected due to pressure Percent of batches rejected due to dwell time All valid batches mistakenly included in the file NOTE: It is possible that a specific batch may have been rejected for more than one reason. 2. Make sure to use meaningful variable names and proper line spacing. 3. Include as comments in your program your name and a brief description of the programExplanation / Answer
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
int main()
{
ifstream read;
ofstream output;
int count=0, dwellfail=0, tempfail=0, pressfail=0, temperature[5], pressure[5], dwell[5], batch[10];
char infile[20],opfile[20];
cout << " Enter the name of input file ";
cin >> infile;
cout << " Enter the name of output file ";
cin >> opfile;
output.open(opfile);
int n,m,o,p,i=1,lines;
ifstream read(infile);
while(!read.eof())
{
read>>n>>m>>o>>p;
batch[i]=n;
temperature[i]=m;
pressure[i]=o;
dwell[i]=p;
i++;
} lines= i;
if(!read)
{
if(temperature == -99 || dwell == -99);
cerr << "Error when opening input file " << filename << endl;
return(1);
}
for (i = ;i<lines;i++)
{
if(temperature[i]< 150 || temperature[i] >170 )
{ tempfail ++; count++;}
if(pressure[i] <60 || pressure[i] > 70)
{ presfail ++; count++;}
if(dwell[i] < 2 || dwell[i] > 2.5)
{ dwellfail ++; count++;}
}
if(count>1)
{
for(i=0;i<count;i++)
{
output << batch[i] << temperature[i] << pressure[i] << dwell[i];
}
cout << " number of temperature rejections "<< tempfail <<" percent is "<< tempfaillines*100 endl;
cout << " number of pressure rejections "<< pressfail <<" percent is "<<pressfaillines*100 endl;
cout << " number of dwells rejections "<< dwellfail <<" percent is "<<dwellfaillines*100 endl;
}
read.close();
output.close();
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.