Question

Please create a c++ program that will ask a high school group that is made of...

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)

Homework Answers

Answer #1
#include <iostream>
#include<string>
using namespace std;

/* macros to define selling price and cost price of small and large boxes */
#define SMALL_BOX_COST_PRICE 4
#define LARGE_BOX_COST_PRICE 6
#define SMALL_BOX_SELLING_PRICE 7
#define LARGE_BOX_SELLING_PRICE 13

/* structure to save information for each student */
struct studentInfo
{
    int smallBox;
    int largeBox;
    int profit;
    string name;
};

int main()
{
    studentInfo arrayStudentInfo[17]; /*maximum 17 students can be there*/
    int numStudents;
    int totalSmallBox=0;
    int totalLargeBox=0;
    int totalProfit = 0;
    cout<<"Please enter number of students participating in drive ::";
    while(true) /*infinite loop to make sure that number of students are between 5 and 17 */
    {
        cin>>numStudents;
        if(numStudents>=5 && numStudents<=17) /* if number of students entered is correct, break to come out of loop*/
        {
            break;
        }
        cout<<"Number of students must be between 5 & 17 ::";
    }
    
    /* loop to get student info */
    for(int i=0;i<numStudents;i++)
    {
        cout<<"Enter information for student#"<<i+1;
        cout<<"\nEnter name :: ";
        cin>>arrayStudentInfo[i].name;
        cout<<"Enter number of small boxes sold :: ";
        cin>>arrayStudentInfo[i].smallBox;
        cout<<"Enter number of large boxes sold :: ";
        cin>>arrayStudentInfo[i].largeBox;
        /*calculate student profit by subtacting cost price from selling price */
        arrayStudentInfo[i].profit = arrayStudentInfo[i].smallBox * SMALL_BOX_SELLING_PRICE + arrayStudentInfo[i].largeBox * LARGE_BOX_SELLING_PRICE - (arrayStudentInfo[i].smallBox * SMALL_BOX_COST_PRICE + arrayStudentInfo[i].largeBox * LARGE_BOX_COST_PRICE);
    }
    
    /* loop to calculate total small boxes , large boxes and profit */
    for(int i=0;i<numStudents;i++)
    {
        totalSmallBox = totalSmallBox +  arrayStudentInfo[i].smallBox;
        totalLargeBox = totalLargeBox + arrayStudentInfo[i].largeBox;
        totalProfit = totalProfit + arrayStudentInfo[i].profit;
    }
    
    cout<<"\nTotal number of students participated are :: "<<numStudents;
    cout<<"\nTotal number of small boxes sold are :: "<<totalSmallBox;
    cout<<"\nTotal number of largeBox boxes sold are :: "<<totalLargeBox;
    cout<<"\nTotal profit made by group is :: "<<totalProfit;

    return 0;
}

Please upvote if u like answer otherwise comment for clarification.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
please create a C++ program that will ask the user how many times to roll a...
please create a C++ program that will ask the user how many times to roll a pair of dice. The choices are 10, 20 & 50. Allow the user to select 1 choice and error if none of the choices are valid. The program will then the desired amount. The program will keep track of the running total of the sum of the dice (i.e. 5, 2 = 7; 3,6 =7+9 = 16). The program will then produce the total...
Ice Cream Program Assignment Write a program in c# that uses a function to ask the...
Ice Cream Program Assignment Write a program in c# that uses a function to ask the user to choose an ice cream flavor from a menu (see output below.) You must validate the users input for the flavor of ice cream accounting for both upper and lower-case letters. You must give them an appropriate error message and allow them to try again.   Once you have a valid flavor, your function will return the flavor back to the main() function.   ...
Please use excel to solve: A convenience store has three different sizes of slushies. The small...
Please use excel to solve: A convenience store has three different sizes of slushies. The small sells for 1.35, the medium sells for 1.65 and the large sells for 2.10. They solde 250 slushies in one day and made 342.75. They sold half as many mediums as the total of small and large combined. How many of each size did they sell?
C++. Write a program that draws a rocket shape on the screen based on user input...
C++. Write a program that draws a rocket shape on the screen based on user input of three values, height, width and stages. The type of box generated (i.e.. a hollow or filled-in) is based on a check for odd or even values input by the user for the box height (or number of rows). Here is the general specification given user input for the height of the box..... Draw a hollow box for each stage if the value for...
Q1. Recently, there has been a noticeable increase in the demand on cryptocurrency investments. As a...
Q1. Recently, there has been a noticeable increase in the demand on cryptocurrency investments. As a result, many online companies have created electronic exchange apps to facilitate the process of buying and selling cryptocurrencies online. For this assignment, you are asked to mimic a simple cryptocurrency exchange applications. a. Create the following VB windows form: (5 points) - Make the title of the form “Redbirds Exchange”. - Disable the textboxes under Buy/Sell. - Make the GroupBox invisible (it is visible...
Need to see step by step solutions Please: Solve Problem and Applications: ch 13- prob 7...
Need to see step by step solutions Please: Solve Problem and Applications: ch 13- prob 7 [Klein Industries manufactures three types of portable air compressors] in page 451 at the end of chapter 13 in your textbook, USA 5th edition. The data is given as part of the question. There is no external data set provided. Use what is given by the problem. You need to submit a formal APA paper to explain all your findings together with your Excel...
PLEASE READ THE ARTICLES ATTACHED AND ANSWER THE FOLLOWING QUESTION. THE ARTICLES ARE BOTH LISTED PLEASE...
PLEASE READ THE ARTICLES ATTACHED AND ANSWER THE FOLLOWING QUESTION. THE ARTICLES ARE BOTH LISTED PLEASE PROVIDE DETAILED EXPLANATIONS. PLEASE WRITE ONE REFLECTION COMBINING BOTH ARTICLES. The purpose of the Article Reflection is to deepen your engagement with the topic of Epidemiology. It will give you the opportunity to reflect on the current real-life epidemiological issues at hand and help to bring meaning to them. ARTICLE 1: A group of students knew they had covid-19. They hosted a party over...
1.A fair die is rolled once, and the number score is noted. Let the random variable...
1.A fair die is rolled once, and the number score is noted. Let the random variable X be twice this score. Define the variable Y to be zero if an odd number appears and X otherwise. By finding the probability mass function in each case, find the expectation of the following random variables: Please answer to 3 decimal places. Part a)X Part b)Y Part c)X+Y Part d)XY ——- 2.To examine the effectiveness of its four annual advertising promotions, a mail...
Plagiarism Certification Tests for Undergraduate College Students and Advanced High School Students These tests are intended...
Plagiarism Certification Tests for Undergraduate College Students and Advanced High School Students These tests are intended for undergraduate students in college or those under 18 years of age. Read these directions carefully! The below test includes 10 questions, randomly selected from a large inventory. Most questions will be different each time you take the test, You must answer at least 9 out of 10 questions correctly to receive your Certificate. You have 40 minutes to complete each test, and you...
CASE STUDY: DATA WAREHOUSING AT VOLVO Every Volvo car has hundreds of microprocessors and sensors. Their...
CASE STUDY: DATA WAREHOUSING AT VOLVO Every Volvo car has hundreds of microprocessors and sensors. Their data is used in diagnosis and repair. It is also captured by Volvo, integrated with the company's CRM, dealership and product data stores, and stored for analysis. This enables Volvo to spot design and construction flaws early, enable proactive correction of faults, and see how its cars respond in accidents. Volvo sells about 400,000 cars per year. Each generates 100–150 kB of data per...