Question: Please add the code wherever it says ADD CODE HERE. 1. Lab3A Sentinel loop & functions 1.1 Complete the following program named Lab3A.cpp //Lab 3A

Please add the code wherever it says ADD CODE HERE. 1. Lab3A Sentinel loop & functions 1.1 Complete the following program named Lab3A.cpp //Lab 3A #include #include #include using namespace std; double readData(double SENT, ifstream *Openfile);

int main ( ) { const double SENT = -999.99; ifstream OpenFile("Lab3AData.txt");

//Declare variables double overallSum; double groupSum; // initialize overall variables // [ADD CODE HERE] // Write a While loop that will loop through and // read in as many inputs as are in the file // use (OpenFile.eof)) // [ADD CODE HERE] // initialize group variables // [Add code here] // Call the readData Function here. // It will calculate and return the sum of // a group of numbers // [ADD CODE HERE] // Increase the overall sum with the // group sum // [ADD CODE HERE] // Display needed output. // [ADD CODE HERE] //end of "end of file" loop // [ADD CODE HERE] // Display needed output. // [ADD CODE HERE]

return 0; } // end of main function double readData(double sent, ifstream *Openfile) {

// Declare any variables need for the function // [ADD CODE HERE] // read in the first // number from the file. // [ADD CODE HERE] // Write a SENTINEL loop to continue until the SENTINEL // is read in // [ADD CODE HERE] // Calculate the sum // [ADD CODE HERE] // read in the next // number from the file. // [ADD CODE HERE] // End of SENTINEL loop // [ADD CODE HERE] // Return the sum // [ADD CODE HERE] } // end of sumData Function 1.2 Add code where it says to finish the program. Make sure you import any needed classes. 1.3 Use the following input to test your program using file redirect. //Name this in file Lab3Adata.txt 0.7497790548868464 0.6462076498775827 0.32616335534841256 0.37582682849958304 -999.99 0.41621372481399 0.6463706270883212 0.7655177221930171 0.2650562905607654 0.14762994129539841 0.9627229328823885 -999.99 0.08133929860959621 0.9560335264804165 0.8155875415237163 -999.99 0.019074104888079813 0.8270564200270186 -999.99 1.4 Compile & Run your program with input data (Lab3A.data.txt) 1.5 Given the in file in Step 3 your out file should look like the following. The previous group had a sum of 2.10. The current overall total had a sum of 2.10. The previous group had a sum of 3.20. The current overall total had a sum of 5.30. The previous group had a sum of 1.85. The current overall total had a sum of 7.15. The previous group had a sum of 0.85. The current overall total had a sum of 8.00. The overall total had a sum of 8.00.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!