Menu

Write C Program Processes Set Sales Data Program First Prompt User Number Months Sales Dat Q43907903

Write a C++ program that processes a set of sales data. Your program will first prompt the user for the number of months of sThe bar chart (and suggested coordinates) generated for the example sales data is shown below: 250, 25 375, 26 C++ Graphics Qwhich results in an integer value of 0. Since the minimum allowable value for height is 1, reset height to 1 (not 0). ObserveRequired Functions The following functions are required when implementing this program. You are free to add any extra functiovoid displayResults (int sales[], int no_months, int max, int min, double avg); Displays the complete bar chart diagram as sh

SALES

Write a C++ program that processes a set of sales data. Your program will first prompt the user for the number of months of sales data to process as shown below: Enter number of months to process: (between 3 and 6 inclusive):6 The minimum months that can be processed are 3, while the maximum number of months that can be processed is 6. A value of 6 is entered for the example given above. Next, the user is prompted for the sales data. The sales data should be stored as integer data within an integer array with the maximum number of elements set to 6. Any non- zero integer value is valid. Example sales data entry is shown below: Enter sales for month #1: 1250 Enter sales for month #20 100 Enter sales for month #3: 13000 Enter sales for month #4: 10000 Enter sales for month #5: 6000 Enter sales for month #6: 3000 For this example, month #1 corresponds to January, month #2 corresponds to February, and so on up to June corresponding to month #6. This program will next display the sales data in the form of a bar chart. The bar chart that this program generates consists of the following: 1. An x/y axis 2. Rectangles representing the percentage of sales for a given month 3. The given month’s abbreviation displayed above its rectangle 4. An image and text used as the bar chart’s heading/title 5. An informational box containing a summary of the sale’s data statistics The bar chart (and suggested coordinates) generated for the example sales data is shown below: 250, 25 375, 26 C++ Graphics QOX Sales for 6 months SALES Monthly Sales May June 200, 280 Feb Months Sales Statistics 200, 345 – 205, 380 Max Sales: $13000 Min Sales: $100 Avg Sales: $5558 Note that the height of each rectangle is based on the sales for that given month. The equation for computing the height for each rectangle is: height = ((double) sales[i]/max) *100.0; where sales[i] is the ith sales value, and max is the maximum sales value (for this example its 13000). The variable height is measured in pixels and should be declared as an int. The minimum value for height is set to 1 (not 0). In other words, if height<1, reset it to exactly 1. The suggested width of each rectangle is 50. The suggested horizontal distance between each rectangle is 25. The suggested length of the vertical axis is 150px while the suggested length of the horizontal axis is 440px. Note: For this example, the height for Feb is computed as height = (100/13000)*100 which results in an integer value of 0. Since the minimum allowable value for height is 1, reset height to 1 (not 0). Observe that there is a very small green rectangle under the Feb heading that has a height of only 1 pixel. This is due to the sales for the month of Feb is < 1. Each month’s rectangle should be colored as follow: January – Red (255,0,0) February – Green (0,255,0) March – Blue (0,0,255) April – Yellow (255,255,0) May – Magenta (255,0,255) June – Turquoise (0,255,255) The heading area of the bar graph should contain an image (sales.bmp) and a text string. sales1.bmp is shown below: The text string portion of the title should indicate the number of months being processed. For this example, the number of months is 6, and the title string appears as: Sales for 6 months The month’s abbreviation should be displayed at the upper left edge of each rectangle. The month’s abbreviations for this program are shown below: Month January February March April May June Abbreviation Jan Feb Mar Apr May June The sales statistics consist of the following: Max Sales Min Sales Average Sales All statistics should be computed as integer values (this includes the Average Sales too). Required Functions The following functions are required when implementing this program. You are free to add any extra functions that you like. int getNoMonths(); Prompts the user for the number of months to process for the sales data. Valid entries are between 3 and 6 inclusively. Return Value: An integer corresponding to the number of months void get Sales (int sales[], int no_months); Prompts the user for the sales data. Correspoinding data is stored in parameters sales. Parameter: no_months – Number of months of sales data to process. Parameter: sales – Array of integers used for storing the sales data as entered by the user. Any positive integer (including zero) is valid. int getMax (int sales [], int no_months); Determines the maximum value from the array of sales. Paramter: sales – Array of integers containing the sales data. Parameter: no_months – Number of months of sales data to be processed. Return Value: The maximum value stored in the sales array int getMin(int sales[], int no_months); Determines the minimum value from the array of sales. Parameter: sales – Array of integers containing the sales data. Parameter: no months – Number of months of sales data to be processed. Return Value: The minimum value stored in the sales array double getAverage (int sales[], int no_months); Computes the average of all sales stored in the sales array. Parameter: sales – Array of integers containing the sales data. Parameter: no_months – Number of months of sales data to be processed. Return Value: The average computed over all values stored in the sales array. void displayResults (int sales[], int no_months, int max, int min, double avg); Displays the complete bar chart diagram as shown on page 2. Use all specifications provided in the overviw section on page 2. Parameter: sales – Array that contains the sales data used for generating the bar char. Parameter: no_months – Number of months (i.e., entries) of sales data to be processed. Should be between 3 and 6 inclusively. Parameter max: The maximum sales value (as determined by getMax). Parameter min: The minimum sales values (as determined by getMin). Parameter avg: The average sales value (as computed by getAverage) Special Note The example screen capture is provided only as an example of what the results should look like. You will not be deducted points if your results are not identical to the one shown (your results should be neatly done and readable though). SALES Show transcribed image text Write a C++ program that processes a set of sales data. Your program will first prompt the user for the number of months of sales data to process as shown below: Enter number of months to process: (between 3 and 6 inclusive):6 The minimum months that can be processed are 3, while the maximum number of months that can be processed is 6. A value of 6 is entered for the example given above. Next, the user is prompted for the sales data. The sales data should be stored as integer data within an integer array with the maximum number of elements set to 6. Any non- zero integer value is valid. Example sales data entry is shown below: Enter sales for month #1: 1250 Enter sales for month #20 100 Enter sales for month #3: 13000 Enter sales for month #4: 10000 Enter sales for month #5: 6000 Enter sales for month #6: 3000 For this example, month #1 corresponds to January, month #2 corresponds to February, and so on up to June corresponding to month #6. This program will next display the sales data in the form of a bar chart. The bar chart that this program generates consists of the following: 1. An x/y axis 2. Rectangles representing the percentage of sales for a given month 3. The given month’s abbreviation displayed above its rectangle 4. An image and text used as the bar chart’s heading/title 5. An informational box containing a summary of the sale’s data statistics
The bar chart (and suggested coordinates) generated for the example sales data is shown below: 250, 25 375, 26 C++ Graphics QOX Sales for 6 months SALES Monthly Sales May June 200, 280 Feb Months Sales Statistics 200, 345 – 205, 380 Max Sales: $13000 Min Sales: $100 Avg Sales: $5558 Note that the height of each rectangle is based on the sales for that given month. The equation for computing the height for each rectangle is: height = ((double) sales[i]/max) *100.0; where sales[i] is the ith sales value, and max is the maximum sales value (for this example its 13000). The variable height is measured in pixels and should be declared as an int. The minimum value for height is set to 1 (not 0). In other words, if height

Expert Answer


Answer to Write a C++ program that processes a set of sales data. Your program will first prompt the user for the number of months…

OR