Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ program, Don't use anything too complicated just functions, whiles, and if's along with basic stuff. Example at bottem for how the output is supposed
C++ program, Don't use anything too complicated just functions, whiles, and if's along with basic stuff.
Example at bottem for how the output is supposed to look.
WRITING FUNCTIONS ASSIGNMENT OVERVIEW This lab will provide practice in writing functions in C++. You will utilize functions to track sales of candy for a band booster fundraiser. CREATING USER-DEFINED FUNCTIONS Defining your own functions allows you to make your code modular and less redundant. Instead of repeating a section of code, you can package it into a function which you can call each time that you want to perform the same or similar calculation or operation. One approach to programming is to create an outline of the steps you wish to follow in your main program, then code up each step as a user-defined function. For each function, you will want to determine: 1. The task that the function will accomplish. Will you compute the average, print a row of a table, or prompt the user for a set of values? Pick a descriptive name for the function based upon its task. For example, calcAvg, printRow, or promptUser would be great names for the functions mentioned above. 2. The parameters that must be passed to the function to accomplish the task. For example, does the function need a set of values to complete the calculation or the Fahrenheit temperature value to convert to Celsius and Kelvin? How many parameters are there and what data type are they? Note, any variable such as a loop control variable for a loop within the function should be declared as a local variable and NOT passed to the function. 3. The single value that the function returns and its return type. For each function that you plan, write out the answer to each of the above items and create a prototype. This will make for a clearer design of your code. BAND BOOSTER PROCEEDS Today you will write a program with 4 functions in addition to ma in to keep track of the total boxes of candy sold as a fundraiser by the band booster club and the total profit made. You will also indicate the total number of boxes sold by each member and the prize level for which they qualify. Your functions will be named updateSales, printinfo, prizeLevel, and profit. In the main function, prompt your user to input the total number of members for which they have data. After that initial value, the data input will be the first and last names and the number of boxes of candy they sold for each of 5 weeks for one member at a time. Call a function named updatesales to read in a single member's information, compute and return the total candy sold by that member. For the number of boxes of candy sold each week, your prompt should include the member's name and the week number, for example: Enter the number of boxes sold by Joe Schmoe during week 1: The prize level achieved by each member should be determined by a function called prizeLevel, which uses a switch statement to return the level using the following scale: Level 1 less than 20 boxes Level 220 or more but less than 50 boxes Level 350 or more but less than 80 boxes Level 480 or more boxes A void function named print info should output the information in the following format: Member name: Joe Schmoe, Total boxes sold: 44, Prize level: 2 Lastly in your main function, output the total boxes of candy sold by ALL members. Call a function named profit to prompt the user to enter the profit per box in dollars that the band keeps, then computes the total profit the band will keep from the candy sales. Return the value and output the total amount from your main function. For example, if the band makes $6.25 per box and 75 total boxes are sold, the output should be: Totalprofitfrombandboostercandysale:$468.75 Use loops as appropriate in your program and resist the urge to use dozens of variables. Ask your lab partner to run your program to give you feedback regarding the clarity of your user prompts. Once your code is completed, tested and fully documented, upload your source code to Blackboard. SAMPLE INPUT AND OUTPUT Enter the number of band booster members: 2 Enter the first and last name of a member: Joe Schmoe Enter the number of boxes sold by Joe Schmoe during week 1:3 Enter the number of boxes sold by Joe Schmoe during week 2:12 Enter the number of boxes sold by Joe Schmoe during week 3:1 Enter the number of boxes sold by Joe Schmoe during week 4:20 Enter the number of boxes sold by Joe Schmoe during week 5:8 Member name: Joe Schmoe, Total boxes sold: 44, Prize level: 2 Enter the first and last name of a member: zoe Doe Enter the number of boxes sold by zoe Doe during week 1:21 Enter the number of boxes sold by zoe Doe during week 2:17 Enter the number of boxes sold by Zoe Doe during week 3:33 Enter the number of boxes sold by Zoe Doe during week 4:25 Enter the number of boxes sold by Zoe Doe during week 5:15 Member name: Zoe Doe, Total boxes sold: 111, Prize level: 4 Total boxes sold: 155 Enter profit per box:\$4.25 Total profit from band booster candy sales: $658.75Step 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