Question
You are asked to write a C program that performs a number of operations based on answers obtained from the user, and the content of
You are asked to write a C program that performs a number of operations based on answers obtained from the user, and the content of a file.
In particular, the new program reads from the file the users living expenses over a number of weeks. Once the budget is determined based on the values read from a file, the program should be able to accept current expenses and provide the user with the updates regarding his/her remaining funds. In order to do so, your program has to read a single file that contains information about expenses related to a number of subcategories for N weeks. A program should determine the weekly amounts spent in each category as an average over N weeks. These amounts will characterize weekly allowances for each category. After this is done, the program should interact with the user. The specification of the program is following:
- the program should read the expenses from the file: cost.txt this file should be downloaded, and put into the same directory where the sources files are; the first line of this file is a number this number tells how many weeks of data are in the file; the rest of the file is a sequence of values where each line represents a value from a single category: fruits/vegetables, next line: others, next line: entertainment. The values for the next week follow.
Example of cost.txt file
2
35.00
65.00
10.00
30.00
75.00
30.00
the meaning of the lines in the file: 2 represents the number of weeks, 35.00 is a cost of fruits/vegetables (1st week), 65.00 is a cost of other expenses (1st week), 10.00 is a cost of entertainment (1st week), and 30.00 is a cost of fruits/vegetables (2nd week), 75.00 is a cost of other expenses (2nd week), 30.00 is a cost of entertainment (2nd week).
- you are asked to sum up these values for each item (fruits/vegetables, others, and entertainment), and calculate average values per week, these average values would represent weekly budget values for each item; they should be displayed and the user should be asked if he/she is okay with the budget values or wants to modify them the only allowed modification is a percentage change, the program should ask the user how many percent he/she want to increase/decrease the budget values; one percentage change for example +10% - should be applied to all categories
- the program provides the user with a chance to enter his/her current expenses, the program should display a new menu:
1) enter expenses
2) show balance
3) exit
if enter expenses is selected, another menu is shown:
1) groceries (fruits, others)
2) entertainment
3) back to main menu
- the program should keep the current balance, where balance = budget-expense, in each category, and be able to display it to the user on demand
- if any of the categories goes below the budget, the program should display a message on the screen: has negative balance, and should allow the user to modify a budget of this category
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started