Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are asked to write a C program that performs a number of operations based on

ID: 3818207 • Letter: Y

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 a file.

In particular, the new program reads from the file the user’s 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

Explanation / Answer

#include <stdio.h>

int main()
{
int choice, choice1;
int g,e;
  
printf("Hello, World! ");
printf("Expense Checker Menu");
printf("1.Enter Expense");
printf("2.Show balance");
printf("3.Exit");
scanf("%d", &choice);
  
switch(choice)
case 1:
printf("1.Enter groceries (fruits, others)");
printf("2. entertainment");
printf("3.back to main menu");
scanf("%d", &choice1);
  
switch(choice1)
  
case 1:
printf("Enter amount");
scanf("%d", &g);
break;
  
case 2:
printf("Enter amount");
scanf("%d", &e);
break;
  
case 3:
main();
break;
  
  
case 2:
Printf("Amount spent on Groceries %D",g);
Printf("Amount spent on Entertainment %D",e);
break;
case 3:
break;
  
default:
break;
  
  


return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote