In: Computer Science
Please create a c++ program that will ask a high school group that is made of 5 to 17 students to sell candies for a fund raiser. There are small boxes that sell for $7 and large ones that sell for $13. The cost for each box is $4 (small box) and $6 (large box). Please ask the instructor how many students ended up participating in the sales drive (must be between 5 and 17). The instructor must input each student’s First name that sold items and enter the number of each box sold each (small or large). Calculate the total profit for each student and at the end of the program, print how many students participated and the total boxes sold for each (small and large) and finally generate how much profit the group made. (15 points)
Code
#include<iostream>
using namespace std;
int main()
{
cout << "Enter number of students participated in sales drive(5-7): ";
int n; //number of students
cin>>n;
string stu[n]; //array to store student names
int tot=0;
int s=0,l=0,p=0;
int ep[n]; //profit of each student
int sb[n],lb[n]; //array of small amd large boxes
for(int i=0;i<n;i++)
{
cout<<"Enter first name of the student "<<(i+1)<<":";
cin>>stu[i];
cout<<"Enter number of small boxes sold by "<<stu[i]<<":";;
cin>>s;
p=p+(s*3); //buy 4 sell 7 profit 3
cout<<"Enter number of large boxes sold by "<<stu[i]<<":";
cin>>l;
p=p+(l*7); //buy 6 sell 13 profit 7
ep[i]=p;
sb[i]=s;
lb[i]=l;
tot=tot+p;
p=0;
}
for(int i=0;i<n;i++)
{
cout<<stu[i]<<" sold "<<sb[i]<<" small boxes and "<<lb[i]<<" large boxes and made profit of $"<<ep[i]<<"\n";
}
cout<<"Total profit that group made is "<<tot;
return 0;
}
Terminal Work
.