Need assistance with my program

I need help wth this assignment for DPR 108. I'm trying to make a program that calculates the average of what you spend in the following categories: food, clothing, school-related expenses, and entertainment. I have to ask the user how they spend each day in each categoy and keep a running total. I have to use static variables to keep track of these amounts, because i want to revisit them in a function containing a loop structure for each day. I also must average out all of the avrerages (that's the easy part). here's what I got so far:

#include <iostream>
using namespace std;
void getscore(static int food, static int clothes, static int school, static int entertain);
void calcaverage(double food, double clothes, double school , double entertain);
int main()
{
static int food; static int clothes; static int school; static int entertain;

cout << "Hello! Let's average out your spending day!\n";
getscore(food, clothes, school, entertain);
cout << "So just to clarify: " << endl;
cout <<food << clothes <<school<< "&"<<entertain << endl;
cout << "Your total average for all of your expenses is: ";
calcaverage(food, clothes, school, entertain);
cout << food << clothes << school << entertain<< endl;
system ("pause");
return 0;
}
void getscore(static int food, static int clothes, static int school, static int entertain);
{
cout<< "Please enter the amount you spend on food each day ";
cin >> food;
cout<< "Please enter the amount you spend clothes each day ";
cin >> clothes;
cout<<"Please enter the amount you spend on school-related expenses each day ";
cin >> school;
cout<<"Please enter the amount you spend on outside entertainment each day ";
cin >> entertain;
}
void calcaverage(double food, double clothes, double school , double entertain);
{
cout <<"Your total average for all of your expenses is: "<< (food+clothes+school+entertain) / 4 << endl;
cout <<"Thank You and enjoy the remainder of your day"<<endl;

}


and here are my error messages at this point:

3 E:\CPP Files\final_exam.cpp storage class specifiers invalid in parameter declarations (same thing for the other three variables in all locations)
3 E:\CPP Files\final_exam.cpp storage class specified for parameter `food' (same thing for the other threee variables in all locations)
20 E:\CPP Files\final_exam.cpp expected unqualified-id before '{' token
20 E:\CPP Files\final_exam.cpp expected `,' or `;' before '{' token
30 E:\CPP Files\final_exam.cpp declaration of `calcaverage' as array of functions
31 E:\CPP Files\final_exam.cpp expected unqualified-id before '{' token
31 E:\CPP Files\final_exam.cpp expected `,' or `;' before '{' token

Any and all suggestions are greatly apprieciated. Thanx!
Hi Kraz,

Please put your code in code brackets next time (it's the <> button in the list of Formatting options). Also, look at the code in your book and try to mimic their formatting using tabs and so forth. Your code should not be written all along the left side of the screen, as it makes it very hard to read.

First off, what exactly do you need to keep track of? A running total of what? The average spent per day? The average spent on a certain item over a number of days? This will have a large impact on how you go about creating your functions and storing your data.
Ok well I need to keep a running total of each input for how nmuch I spend per day.
Kraz, try this:
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
#include <iostream>
using namespace std;
void getscore(int food, int clothes, int school, int entertain);
void calcaverage(double food, double clothes, double school , double entertain);
int main()
{
static int food; static int clothes; static int school; static int entertain;

cout << "Hello! Let's average out your spending day!\n";
getscore(food, clothes, school, entertain);
cout << "So just to clarify: " << endl;
cout <<food << clothes <<school<< "&"<<entertain << endl;
cout << "Your total average for all of your expenses is: ";
calcaverage(food, clothes, school, entertain);
cout << food << clothes << school << entertain<< endl;
system ("pause");
return 0;
}
void getscore(static int food, static int clothes, static int school, static int entertain)
{
cout<< "Please enter the amount you spend on food each day ";
cin >> food;
cout<< "Please enter the amount you spend clothes each day ";
cin >> clothes;
cout<<"Please enter the amount you spend on school-related expenses each day ";
cin >> school;
cout<<"Please enter the amount you spend on outside entertainment each day ";
cin >> entertain;
}
void calcaverage(double food, double clothes, double school , double entertain)
{
cout <<"Your total average for all of your expenses is: "<< (food+clothes+school+entertain) / 4 << endl;
cout <<"Thank You and enjoy the remainder of your day"<<endl;

}

You only need the semicolon(';') after the PROTOTYPE of a function, not in the actual DECLARATION!
And, for the statics, they are just storage classifiers, you add them in the variable declaration, not in the function parameter list!
viliml. This gave me errors like"storage class specifiers invalid in parameter declarations " and storage class specified for parameter'food'."
These same errors show up for the other three categories too. What does it mean?
This is the full description of my assignment:

Write a program that calculates how much money you are spending on average per day in a week. The program will calculate the total average, as well as the average of what you spend in the following categories: food, clothing, school-related expenses, and outside entertainment. You will ask the user how much he/she spends in each category for each day and keep a running total for each category. Use static variables to keep track of these amounts, as you will revisit a function containing the loop structure(s) for each day. You will also need an average function that calculates all of the averages. Organize the main program to call input and output functions. The input function will be responsible for updating the totals, and the output function will calculate and display the results. Note that these functions will most likely call other functions to accomplish tasks. Use value and reference parameters as necessary.
Last edited on
Topic archived. No new replies allowed.