A student has established the following monthly budget: Housing 500.00 Utilities
ID: 3548358 • Letter: A
Question
A student has established the following monthly budget:
Housing
500.00
Utilities
150.00
Household Expenses
65.00
Transportation
50.00
Food
250.00
Medical
30.00
Insurance
100.00
Entertainment
150.00
Clothing
75.00
Miscellaneous
50.00
Write a modular program that declares a MonthlyBudget structure with member variables to hold each of these expense categories. The program should create two MonthlyBudget structure variables. The first will hold the budget figures given above. The second will hold the user-enter amounts actually spent during the past month. The program should create a screen form that displays each category name and its budgeted amount, then positions the cursor next to it for the user to enter the amount actually spent in that category. Once the user data has all been entered, the program should compute and display the amount over or under budget the student's expenditures were in each category, as well as the amount over or under budget for the entire month.
Housing
500.00
Utilities
150.00
Household Expenses
65.00
Transportation
50.00
Food
250.00
Medical
30.00
Insurance
100.00
Entertainment
150.00
Clothing
75.00
Miscellaneous
50.00
Explanation / Answer
==============
Modular Program
==============
program StudentMonthlyBudget
use subroutine input to get the values for Housing,Utilities,HouseholdExpenses,Transportation,Food,Medical,Insurance,Entertainment,Clothing,Miscellaneous
call input(Housing,Utilities,HouseholdExpenses,Transportation,Food,Medical,Insurance,Entertainment,Clothing,Miscellaneous)
find the sum of Housing and Utilities and HouseholdExpenses and Transportation and Food and Medical and Insurance and Entertainment and Clothing and Miscellaneous
call add(Housing,Utilities,HouseholdExpenses,Transportation,Food,Medical,Insurance,Entertainment,Clothing,Miscellaneous,TotalBudget)
use the subroutine output to send the results to the screen
call output(Housing,Utilities,HouseholdExpenses,Transportation,Food,Medical,Insurance,Entertainment,Clothing,Miscellaneous,TotalBudget)
stop
end
------------------------------
subroutine add (Housing,Utilities,HouseholdExpenses,Transportation,Food,Medical,Insurance,Entertainment,Clothing,Miscellaneous,TotalBudget)
------------------------------
Add all and store the sum in "TotalBudget"
TotalBudget = Housing+Utilities+HouseholdExpenses+Transportation+Food+Medical+Insurance+Entertainment+Clothing+Miscellaneous
return
end
------------------------------
subroutine input (Utilities,HouseholdExpenses,Transportation,Food,Medical,Insurance,Entertainment,Clothing,Miscellaneous,TotalBudget)
------------------------------
print *, ' This program adds all'
print *, ' Type expenses in now separated by a comma or space'
Now read the all expenses that are typed by the user
this Fortran read will wait until the numbers are typed
read *, Utilities,HouseholdExpenses,Transportation,Food,Medical,Insurance,Entertainment,Clothing,Miscellaneous,TotalBudget
return
end
------------------------------
subroutine output (Housing,Utilities,HouseholdExpenses,Transportation,Food,Medical,Insurance,Entertainment,Clothing,Miscellaneous,TotalBudget)
------------------------------
Print out the results with a description
print *, ' The sum of ', Housing,' and ' , Utilities,' and ' ,HouseholdExpenses,' and ' ,Transportation,' and ' ,Food,' and ' ,Medical,' and ' ,Insurance,' and ' ,Entertainment,' and ' ,Clothing,' and ' ,Miscellaneous
print *, ' is ' , TotalBudget
return
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.