Need assistance with my Functions!!!

Struggling with this, can't seem to get it to work. Here is what I need to do:
1. Ask the user how many weeks were in the landscaping season this year.
2. Dynamically create an array of double floating point data that can be used to store the sales for each week of the season.
3. Using a for loop, have the user enter in the sales data for the season.
4. Pass the array (and its size) into a function that will display all the sales for the weeks in a nice table.
5. Call another function that will take in the array as an argument and will total the sales for the season (returning the total to the main function).
6. Have the program tell the user the total sales for the season and the average sales per week.
7. After this delete the allocated memory and set the pointer to 0.

Any assistance helps always I don't quite understand functions, or pointers. and I've read about both a lot!!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

#include <iostream>
#include <iomanip>
using namespace std;


int Weeks = 0;
double total;
double sales;
void SalesTable(int);
double Total (int, double[]);
double average;

int main()
{
    double Season[Weeks];
    
    cout << "How many weeks were in the landscaping season this year: ";
    cin >> Weeks;
   
    for (int i = 1; i<Weeks+1; i++)
    {
        cout << "Enter sales data for week " << i <<": ";
        cin >> sales;
    }
    Season[Weeks]=sales;
    
    SalesTable(Weeks);
    Total(Weeks, Season);
    
    average = total/Weeks;
    
    cout << "The total sales for the season are: "<<setprecision(2)<<showpoint<<fixed<<total<< endl;
    cout << "The average weekly sales were: "<<setprecision(2)<<showpoint<<fixed<<average;
    return 0;
}
void SalesTable(int Weeks)
{
    for(int i = 1; i<Weeks+1; i++)
    {
        cout << "Sales for week "<< i <<":" << sales <<endl;
    }
}
double Total(int Weeks, double Season[])
{
    for(int i = 1; i<Weeks+1; i++)
    {
        total += Season[Weeks];
    }
    return total;
}
Topic archived. No new replies allowed.