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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
  1. 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
     
  2. 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.95
    Sample 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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Array
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.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education