Hello! I'm new at c++ and I ve already missed some lectures so I am really confused about this assignment!
Can anyone help me?
Problem 1 - “Largest and Smallest Numbers”
Write a program that reads nonnegative integers from a data file and then outputs the largest and the smallest values onto the console. Assume that a negative number marks the end of the input data file. The input file is on Blackboard in the Lab #7 Data Files folder.
Input File Name: Lab_7_Largest_and_Smallest_Numbers.dat
Note: You must use a C++ loop in this program.
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.
There are two things I think you should know to make these programs work if you don't already. One would be reading data in from a file, the other would be std::vectors. You'll also need to know about structs to make the second program easier, here's a link: http://cplusplus.com/doc/tutorial/structures/
About using vectors... hey, that's going to be my next article!
At the top of your C++ file, #include <vector> . This will let you use vectors, which are like arrays except that you can easily make them bigger at runtime.
Here are a few code snippets to help you with the ropes:
1 2 3 4
std::vector<type> name; //Creates an empty vector. You can expand it later, if you want.
name[position]; //Just like with arrays.
name.push_back(data); //Adds a copy of data onto the back of your vector, expanding it. Data must be of the same type as what you entered in the <>s.
name.size(); //Lets you know the size of your vector.