Write a program that calculates how much money you are spending on average per d
ID: 3664713 • Letter: W
Question
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.
Explanation / Answer
Edit & Run
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!
#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! "; 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; } Edit & Run
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.