Answer to Question #90723 in C++ for keotshepile

Question #90723
Students at a local middle school volunteered to sell fresh baked cookies to raise funds to increase the number of computers for the computer lab. Each student reported the number of boxes he/she sold.

Write a program that will ask as input the number of volunteers, the name of the volunteer, and the number of boxes sold by the volunteer. the the program produces as output the total number of boxes of cookies sold, the total revenue generated by selling the cookies, and the average number of boxes sold by each student
1
Expert's answer
2019-06-11T10:46:29-0400
#include <iostream>
using namespace std;

int main() {
    cout << "How many volunteers?\n";
    int vol;
    cin >> vol;

    cout << "What is the price of one box?\n";
    int cost;
    cin >> cost;

    int total = 0;

    for (int i = 1; i <= vol; i++) {
        cout << "Enter name of volunteer " << i << endl;
        string name; //no need to store
        cin >> name;
        cout << "Enter number of boxes sold:\n";
        int boxes;
        cin >> boxes;

        total += boxes;
    }
    cout << "Total number of boxes of cookies sold: " << total << endl;
    cout << "Total revenue generated by selling the cookies: $" << cost * total << endl;
    cout << "Average number of boxes sold by each student: " << (float)total / vol << endl;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS