Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do some modification to the code , after the program has read all the information regarding user savings and expenses for the whole year, the

Do some modification to the code , after the program has read all the information regarding user savings and expenses for the whole year, the program should allow user to select and print the total expenses of a particular month

same as the picture

image text in transcribedmodify to this code :

#include

float Year_Saving(float Saving[12]){ //TO CALCULATE TOTAL SAVING float amount=0; for(int i=0;i

float Year_Bill(float Bill[12]){ //TO CALCULATE TOTAL Electricity BILL float amount=0; for(int i=0;i

float Year_WBill(float WBill[12]){ //TO CALCULATE TOTAL Water BILL float amount=0; for(int i=0;i

float Year_Expenses(float Expenses[12]){ //TO CALCULATE TOTAL Year Expenses float amount=0; for(int i=0;i

float Month_bill(int unit) //TO CALCULATE MONTHLY Electricity BILL { float MBill , EMbill; if(unit201 && unit301 && unit401 && unit501 && unit601 && unit701 && unit801 && unit900){ MBill =(200*21.8)+(300*33.4)+(400*40)+(500*40.2)+(600*41.6)+(700*42.6)+(800*43.7)+(900*45.3)+(unit-900)*45.4 ; } EMbill = MBill / 503.156046 ; return EMbill; }

float Month_W_bill(int Wusage) //TO CALCULATE MONTHLY WATER BILL { float MWBill; if(Wusage 20 && Wusage = 35){ MWBill = (Wusage *1.03) ; } return MWBill; }

// TO CALCULATE MONTHLY EXPENSES AND PRINT float Month_expenses(float EMbill , float MWBill, float EmployeeSalary, float ownSalary, float internet, float rent, float Saving) { float Mexpenses = EMbill + MWBill + EmployeeSalary + ownSalary + internet + rent + Saving ; printf (" Electricity expenses : %f " ,EMbill); printf (" Water expenses : %f " ,MWBill); printf (" Employee Salary : %f " ,EmployeeSalary); printf (" Own Salary : %f " ,ownSalary); printf (" Internet expenses : %f " ,internet); printf (" Rent expenses : %f " ,rent); printf (" Savings : %f " ,Saving); printf (" Your Total expenses for this month is , %f " , Mexpenses); return Mexpenses; }

//THE MAIN FUNCTION int main() { //VARIABLE DECLARATION int income, rent , internet ; float ownSalary , EmployeeSalary , Saving , YSaving , Wusage , Mexpenses , moneyleft=0 , unit , EMbill , MWBill , MBill , YEbill , Yexpenses , YWBill , YBill; float M_Savings[12]; float M_Bill[12]; float MW_Bill[12]; float M_expenses[12];

int x=0 ; income = 2450 ; rent = 300 ; internet = 75 ; ownSalary = ( income * 10 ) / 100 ; EmployeeSalary = (income * 7 ) / 100 ;

//TO ASK USER FOR THE SAVING AMOUNT printf("Enter the amount you want to save every month : "); scanf("%f",&Saving);

//FOR LOOP TO CALCULATE 12 MONTHS INPUT

for (x=0; x

printf(" Enter total units consumed for %d month : ",x+1); scanf("%f",&unit); MBill = Month_bill(unit); M_Bill[x]=MBill; printf("Enter total water usage %d month : ",x+1 ); scanf("%f",&Wusage); MWBill = Month_W_bill(Wusage); MW_Bill[x]=MWBill; printf("Expenses for %d month : ",x+1 ); Mexpenses=Month_expenses( MBill, MWBill, EmployeeSalary, ownSalary, internet, rent, Saving); M_expenses[x]=Mexpenses; moneyleft = income - Mexpenses ; printf (" Your money lest for this month is : %f " , moneyleft) ; M_Savings[x]=Saving; } //TO CALCULATE YEARLY EXPENCESES

YEbill = Year_Bill(M_Bill); YWBill = Year_WBill(MW_Bill); Yexpenses = Year_Expenses(M_expenses); YSaving = Year_Saving(M_Savings);

//TO PRINT YEARLY EXPENCESES printf(" Total 12 months electricity bill = %f ",YEbill ); printf("Total 12 months of Water bill = %f ",YWBill); printf("Total 12 months of House rent = %d ",(rent*12)); printf("Your expenses for a year is = %f ", Yexpenses); printf("Your Savings for a year is = %f ", YSaving); printf("Your money lest for a year is = %f ", (income*12)-Yexpenses); return(0); }

- x CA C:WINDOWS\system32\cmd.exe Select Month: May Electricity usage : RM 45.00 Water consumption: RM 8.00 Internet usage: RM 75.00 House rent: RM300.00 Savings : RM 60.00 Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is Accounting?

Answered: 1 week ago

Question

Define organisation chart

Answered: 1 week ago

Question

What are the advantages of planning ?

Answered: 1 week ago

Question

Additional Factors Affecting Group Communication?

Answered: 1 week ago