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...


Instructions


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


Assume that the data is provided in a file calledCh5_Ex18Data.txt and 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.






Provided data file Ch5_Ex18Data.txt info



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




//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 <><><>


    cout <>

<><>

<>

<><>




    totalNumOfBoxesSold = 0;

    numOfVolunteers = 0;


    cin >> name;


    while (name != SENTINEL)

    {

        cin >> numOfBoxesSold;

        totalNumOfBoxesSold = totalNumOfBoxesSold

                              + numOfBoxesSold;

        numOfVolunteers++;


        cin >> name;

    }


    cout <>

    cout <>

<><>


    cout <>

    cin >> costOfOneBox;

    cout <>


    cout <>

<>

<><>


    if (numOfVolunteers != 0)

        cout <>

 <>

 < totalnumofboxessold >

 <>

    else

        cout <><>

    return 0;

}

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here