Question: Assume that the data is provided in a file called Ch 5 _ Ex 1 8 Data.txt and the first line in the file specifies
Assume that the data is provided in a file called ChExData.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 EOFcontrolled loop to process the data from the text file.
#include
#include
#include
using namespace std;
const string SENTINEL ;
int main
string name;
int numOfVolunteers;
int numOfBoxesSold;
int totalNumOfBoxesSold;
double costOfOneBox;
cout fixed showpoint setprecision;
cout "Line : Enter each volunteer's name and
"the number of boxes endl
sold by each volunteer, ending
"with : endl;
totalNumOfBoxesSold ;
numOfVolunteers ;
cin name;
while name SENTINEL
cin numOfBoxesSold;
totalNumOfBoxesSold totalNumOfBoxesSold
numOfBoxesSold;
numOfVolunteers;
cin name;
cout endl;
cout "Line : The total number of boxes sold:
totalNumOfBoxesSold endl;
cout "Line : Enter the cost of one box: ;
cin costOfOneBox;
cout endl;
cout "Line : The total money made by selling
"cookies: $
totalNumOfBoxesSold costOfOneBox endl;
if numOfVolunteers
cout "Line : The average number of
"boxes sold by each volunteer:
totalNumOfBoxesSold numOfVolunteers
endl;
else
cout "Line : No input." endl;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
