Instructions The program in Example 5-4 uses a sentinel control loop to process cookies sales data. Assume that the data is provided in a file called Ch5_Ex18Data.txt and the first line in the file...

1 answer below »


Instructions


The program inExample 5-4uses a sentinel control loop to process cookies sales data.


Assume that the data is provided in a file calledCh5_Ex18Data.txtand the first line in the file specifies the cost of one box.


Modify the program (inmain.cpp) so that it uses an EOF-controlled loop to process the data.




Instructions The program in Example 5-4 uses a sentinel control loop to process cookies sales data. Assume that the data is provided in a file called Ch5_Ex18Data.txt and the first line in the file specifies the cost of one box. Modify the program (in main.cpp) so that it uses an EOF-controlled loop to process the data. This is the text as shown in this screenshot: 3.50 Sara 120 Lisa 128 Cindy 359 Nicole 267 Blair 165 Abby 290 Amy 190 Megan 450 Eligabeth 280 Meridth 290 Lesile 430 Chelsea 378 This is the code in the .cpp //Program: Sentinel-Controlled Loop //This program computes and outputs the total number of boxes of //cookies sold, the total revenue, and the average number of //boxes sold by each volunteer. #include  #include  #include  using namespace std; const string SENTINEL = "-1"; int main() {     string name;          int numOfVolunteers;     int numOfBoxesSold;     int totalNumOfBoxesSold;          double costOfOneBox;          cout <><>< setprecision(2);     ="">< "line 14: enter each volunteer's name and "><>< endl>< " sold by each volunteer, ending "><>< endl;     =""     totalnumofboxessold =" 0;"     numofvolunteers =" 0;"     =""     cin ="">> name;          while (name != SENTINEL)     {         cin >> numOfBoxesSold;         totalNumOfBoxesSold = totalNumOfBoxesSold                               + numOfBoxesSold;         numOfVolunteers++;                  cin >> name;     }          cout < endl;>< "line 26: the total number of boxes sold: "><>< endl;     ="">< "line 27: enter the cost of one box: ";     cin ="">> costOfOneBox;     cout < endl;     ="">< "line 30: the total money made by selling ">< "cookies: $"><>< endl;     =""     if (numofvolunteers !=" 0)">< "line 32: the average number of ">< "boxes sold by each volunteer: ">< totalnumofboxessold   numofvolunteers="">< endl;     else=""><>< endl;     return 0;="" }="" this="" tasks="" 0.00="" out="" of="" 10.00="" correct="" output="" for="" test="" cases="" 1="" 0="" out="" of="" 1="" checks="" passed.="" review="" the="" results="" below="" for="" more="" details.="" checks="" test="" caseincomplete="" test="" case="" 1="" input="" output="" line="" 14:="" enter="" each="" volunteer's="" name="" and="" the="" number="" of="" boxes="" sold="" by="" each="" volunteer,="" ending="" with="" -1:="" results="" 3347="" 11714.5="" 278="" show="" details="" 0.00="" out="" of="" 10.00="" uses="" file="" i/o="" with="" eof-controlled="" loop="" 4="" 0="" out="" of="" 4="" checks="" passed.="" review="" the="" results="" below="" for="" more="" details.="" checks="" code="" patternincomplete="" file="" i/o="" header="" included="" description="" searched="" your="" code="" for="" a="" specific="" pattern:="">.* You can learn more about regular expressions [here](https://ruby-doc.org/core-2.1.1/Regexp.html). Code PatternIncomplete Input file object declared Description Searched your code for a specific pattern: ifstream You can learn more about regular expressions [here](https://ruby-doc.org/core-2.1.1/Regexp.html). Code PatternIncomplete File object opens Ch5_Ex18Data.txt Description Searched your code for a specific pattern: .+\.open\(\s*"Ch5_Ex18Data.txt".+ You can learn more about regular expressions [here](https://ruby-doc.org/core-2.1.1/Regexp.html). Code PatternIncomplete Sentinel loop replaced with EOF-controlled loop Description Searched your code for a specific pattern: .*while\s*\((?!SENTINEL).+(?
Answered 1 days AfterOct 30, 2021

Answer To: Instructions The program in Example 5-4 uses a sentinel control loop to process cookies sales data....

Darshan answered on Oct 31 2021
122 Votes
Ch5_Ex18Data.txt
3.50
Sara 120
Lisa 128
Cindy 359
Nicole 267
Blair 165
Abby 290
Amy 190
Meg
an 450
Eligabeth 280
Meridth 290
Lesile 430
Chelsea...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here