Write a C++ program that will read monthly sales into a dynamically allocated array. The program will input the size of the array from the user (must be less than or equal to 12). It will call a function that will find the sum of all sales. It will also call a function to find the average. It will also call a function to sort the array using either a bubble or selection sort in descending order and then display the results.
Write a C++ program that will read monthly sales into a dynamically allocated array. The program will input the size of the array from the user (must be less than or equal to 12). It will call a function that will find the sum of all sales. It will also call a function to find the average. It will also call a function to sort the array using either a bubble or selection sort in descending order and then display the results.
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 23PE
Related questions
Question
-
Write a C++ program that will read monthly sales into a dynamically allocated array. The program will input the size of the array from the user (must be less than or equal to 12). It will call a function that will find the sum of all sales. It will also call a function to find the average. It will also call a function to sort the array using either a bubble or selection sort in descending order and then display the results.
- You must have a comment block header at the top of your program. See the Standards document in Course Content
- You must use pointers for your arrays and dynamically allocate them based on the number of month
- You must remove and reset the array when completed
- You must use the correct data types for your variables
- You must validate your input.
- The number of months must be between 1 and 12
- You must use a loop to read in the sales
- You must use at least 3 functions to calculate the average, sort the array and display the sales
- Your output should be formatted correctly
- Sales totals, average should have two decimal places
-
Sample Run #1:Please input the number of monthly sales to be input
4
Please input the sales for month 1:
1290.89
Please input the sales for month 2:
905.95
Please input the sales for month 3:
1567.98
Please input the sales for month 4:
994.83
The total sales for the time period is $4759.65
The average month sale is $1189.91
Sales in descending order:
$1567.98
$1290.89
$994.83
$905.95Sample Run #2:Please input the number of monthly sales to be input
0
You must enter a value between 1 and 12. Please reenter.
Please input the number of monthly sales to be input
14
You must enter a value between 1 and 12. Please reenter.
Please input the number of monthly sales to be input
2
Please input the sales for month 1:
959.44
Please input the sales for month 2:
674.11
The total sales for the time period is $1633.55
The average month sale is $816.78
Sales in descending order:
$959.44
$674.11
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 5 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr