this is the work "students at a school volunteered to sell fresh baked cookies to raise funds to increase the number of computers in the computer lab. Each student reported the number of boxes he/she sold. Write a program that wil output the total number of boxes of cookies sold, the total revenue generated by selling the cookies and the saverage number of boxes sold by each student. The programmer do not know the exact number of volunteers involved, we assume that -1 that will mark the end of the data.
Assume the data input is in the following form: student's name followed by a space and the number of boxes sold by the student

Last edited on
Are you reading the data from a file?
idk, i need to make a c++ program based on the informations given
and i need to forward the source file
 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485`` ``````#include #include using namespace std; struct student { string name; int boxesSold; float totalMade; }; float calcAverageBoxes(student [], int); float calctotalRev(student [], int); int calcTotalBoxes(student [], int); int main() { int numStudents; float averageBoxesSold; float totalRevenue; float totalBoxesSold; cout << "How many students were there?" << endl; cout << " >>> "; cin >> numStudents; student info[numStudents]; for(int i = 0; i < numStudents; i++) { cout << "Enter name of first student: "; getline(cin, info[i].name); cout << "Boxes sold for student " << i+1 << ": "; cin >> info[i].boxesSold; cout << "Total made for student " << i+1 << ": "; cin >> info[i].totalMade; } averageBoxesSold = calcAverageBoxes(info, numStudents); totalRevenue = calctotalRev(info, numStudents); totalBoxesSold = calcTotalBoxes(info, numStudents); for(int i = 0; i < numStudents; i++) { cout << "Name: " << info[i].name << endl; cout << "Boxes sold: " << info[i].boxesSold << endl; cout << "Total made: " << info[i].totalMade << endl; } cout << endl << "Total Revenue: " << totalRevenue << endl; cout << "Average boxes sold: " << averageBoxesSold << endl; cout << "Total boxes sold: " << totalBoxesSold << endl; return 0; } float calcAverageBoxes(student info[], int numStudents) { float x = 0.0; for(int i = 0; i < numStudents; i++) { x = x + info[i].boxesSold; } return x/numStudents; } float calctotalRev(student info[], int numStudents) { float x = 0.0; for(int i = 0; i < numStudents; i++) { x = x + info[i].totalMade; } return x; } int calcTotalBoxes(student info[], int numStudents) { int x = 0; for(int i = 0; i < numStudents; i++) { x = x+info[i].boxesSold; } return x; }``````

Haven't tested, not sure it fully works.

Cheers and goodluck
Last edited on
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586`` ``````#include #include using namespace std; struct student { string name; int boxesSold; float totalMade; }; float calcAverageBoxes(student [], int); float calctotalRev(student [], int); int calcTotalBoxes(student [], int); int main() { int numStudents; float averageBoxesSold; float totalRevenue; float totalBoxesSold; cout << "How many students were there?" << endl; cout << " >>> "; cin >> numStudents; student info[numStudents]; for(int i = 0; i < numStudents; i++) { cout << "Enter name of student " << i+1 << ": "; cin.ignore(); getline(cin, info[i].name); cout << "Boxes sold for student " << i+1 << ": "; cin >> info[i].boxesSold; cout << "Total made for student " << i+1 << ": "; cin >> info[i].totalMade; } averageBoxesSold = calcAverageBoxes(info, numStudents); totalRevenue = calctotalRev(info, numStudents); totalBoxesSold = calcTotalBoxes(info, numStudents); for(int i = 0; i < numStudents; i++) { cout << "Name: " << info[i].name << endl; cout << "Boxes sold: " << info[i].boxesSold << endl; cout << "Total made: " << info[i].totalMade << endl; } cout << endl << "Total Revenue: " << totalRevenue << endl; cout << "Average boxes sold: " << averageBoxesSold << endl; cout << "Total boxes sold: " << totalBoxesSold << endl; return 0; } float calcAverageBoxes(student info[], int numStudents) { float x = 0.0; for(int i = 0; i < numStudents; i++) { x = x + info[i].boxesSold; } return x/numStudents; } float calctotalRev(student info[], int numStudents) { float x = 0.0; for(int i = 0; i < numStudents; i++) { x = x + info[i].totalMade; } return x; } int calcTotalBoxes(student info[], int numStudents) { int x = 0; for(int i = 0; i < numStudents; i++) { x = x+info[i].boxesSold; } return x; }``````

Fixed a few things
Last edited on
Thank you so much bro, i owe you