CIS-210 Introduction to C++ Programming (Fall 2017) Assignment-4 Points: 100 Due
ID: 3819108 • 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 tissue before they are shipped to operation. Packages of sutures must be sealed carefully 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 package is called the dwell time. Assume that the 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 program.Explanation / Answer
#include <iostream>
#include <sstream>
#include <string>
#include <fstream>
using namespace std;
int main(){
double temperature[10],pressure[10],dwells[10];
int totalRecords = 0;
double validRecordsFound = 0,tempFailed=0,pressFailed=0,dwellFailed=0;;
std::ifstream infile("suture.dat");
std::string line;
double record,temp,pres,dwell;
while (std::getline(infile, line))
{
std::istringstream iss(line);
double record,temp,pres,dwell;
if (!(iss >> record >> temp >> pres >> dwell)) { break; }
temperature[totalRecords] = temp;
pressure[totalRecords] = pres;
dwells[totalRecords] = dwell;
totalRecords++;
//checking for valid record
if((temp>=150 && temp <= 170) && (pres>=60 && pres<=70) && (dwell >= 2 && dwell <= 2.5)){
cout<<"ERROR: VALID BATCH - "<<record<<" "<<temp<<" "<<pres<<" "<<dwell<<endl;
validRecordsFound++;;
}
//counting wrong records
if(temp<150 || temp > 170){
tempFailed++;
}
if(pres<60 || pres>70){
pressFailed++;
}
if(dwell < 2 && dwell > 2.5){
dwellFailed++;
}
}
//printing final results
if(tempFailed == 0 || pressFailed == 0 || dwellFailed == 0){
cout<<"No Rejected matches";
}
else{
cout<<"Percent of batches rejected due to temperature: "<<(tempFailed/(totalRecords-validRecordsFound))<<endl;
cout<<"Percent of batches rejected due to pressure: "<<(pressFailed/(totalRecords-validRecordsFound))<<endl;
cout<<"Percent of batches rejected due to Dwell: "<<(dwellFailed/(totalRecords-validRecordsFound))<<endl;
}
return 0;
}