Question
(NEEDED IN C++) Pt 1: Five students at a local middle school volunteered to sell fresh baked cookies to raise funds to increase the number
(NEEDED IN C++)
Pt 1: Five 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. Cost of each box of cookies was $4.50. Write a program that will 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 the students. Prompt the user to enter the following information: the StudentID number and the number of boxes sold.
**I have part 1 here I need parts 2 and 3 (below)**
#includeusing namespace std; int main() { //declare variables int SID; double BoxesSold, Total_Box = 0; //total revenue double TotalRev; //avg # of sales double AvgSold; //cost per box double cost = 4.50; //total # of students selling int counter; for (int counter = 1; counter <= 5; counter++) { //prompt user to enter SID cout << "Enter ID number for student " << counter << ": "; cin >> SID; //prompt to enter # of boxes sold by that ID number cout << "Enter number of boxes sold by " << SID << ": "; cin >> BoxesSold; //total Boxes Total_Box = Total_Box + BoxesSold; } // total revenue TotalRev = Total_Box * cost; //Avg # sold by all AvgSold = Total_Box / total; //output total revenue cout << "Total Revenue = $" << TotalRev << endl; //output Average boxes sold cout << "Average boxes sold by " << total << " students = " << AvgSold << endl; } system("pause"); }
~~~~~~~~~~~~
PT 2: In the program above you know the exact number of student volunteers. Now suppose that the programmer does not know the exact number of volunteers. Once again, assume that the data is in the following form, i.e. the students ID number and the number of boxes sold by the student is provided by the user. Prompt the user to enter this information as in Question 1, but here, you do not know the exact number of volunteers, instead -1 will mark the end of the data entered.
PT 3: Finally, redo question 2, but this time declare a Boolean variable and use it to control the while loop.
I know that I need a sentinel loop for pt 2 and a boolean loop for pt 3.
PLEAAASE HELP.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started