Write a program that assists the user to determine a simple budget based on the income entered. Using the system, the income would be divided into four different categories; • Necessity: Typical expenses such as rent, transport, utilities, insurance, etc. Invest: Investment opportunity in real estate, stock market, etc. Play: Amount that can be spent on small luxury such as fine dining, gadget, etc. Charity: Contribution to help other less fortunate person or charitable organization. a) Create a structure called Budget. The attributes in the structure are: o name (string) o age (int) o income (float) o necessity (float) o play (float) o invest (float) o charity (float) Declare a structure variable array called info with size 3.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

in c programming

Write a program that assists the user to determine a simple budget based on the income
entered. Using the system, the income would be divided into four different categories;
Necessity: Typical expenses such as rent, transport, utilities, insurance, etc.
Invest: Investment opportunity in real estate, stock market, etc.
Play: Amount that can be spent on small luxury such as fine dining, gadget, etc.
Charity: Contribution to help other less fortunate person or charitable organization.
a) Create a structure called Budget. The attributes in the structure are:
o name (string)
o age (int)
o income (float)
o necessity (float)
o play (float)
o invest (float)
o charity (float)
Declare a structure variable array called info with size 3.
b) In main() function:
Create a FILE pointer called fp. Use this pointer to open the file Report.txt for
updating. The file contains the name, age, income, necessity, play, invest, charity.
• If the file cannot be opened, display error message "File cannot be opened.
Terminating..." and quit the program.
Call function get_details(...), passing info as argument.
Using a for..loop (repeat for 3 times):
Write the name, age, income, necessity, invest, play and charity into file
report.txt.
Call function display(...), passing info as argument.
Close file Report.txt.
c) In the get details(...) function:
Using a while.loop (repeat for 3 times):
Request from the user to enter data for name, age and income for each
individual.
Calculate the allocation amount according to the following table.
Category
necessity 65% of income
invest
Allocation
20% of income
play
charity
10% of income
5% of income
Transcribed Image Text:Write a program that assists the user to determine a simple budget based on the income entered. Using the system, the income would be divided into four different categories; Necessity: Typical expenses such as rent, transport, utilities, insurance, etc. Invest: Investment opportunity in real estate, stock market, etc. Play: Amount that can be spent on small luxury such as fine dining, gadget, etc. Charity: Contribution to help other less fortunate person or charitable organization. a) Create a structure called Budget. The attributes in the structure are: o name (string) o age (int) o income (float) o necessity (float) o play (float) o invest (float) o charity (float) Declare a structure variable array called info with size 3. b) In main() function: Create a FILE pointer called fp. Use this pointer to open the file Report.txt for updating. The file contains the name, age, income, necessity, play, invest, charity. • If the file cannot be opened, display error message "File cannot be opened. Terminating..." and quit the program. Call function get_details(...), passing info as argument. Using a for..loop (repeat for 3 times): Write the name, age, income, necessity, invest, play and charity into file report.txt. Call function display(...), passing info as argument. Close file Report.txt. c) In the get details(...) function: Using a while.loop (repeat for 3 times): Request from the user to enter data for name, age and income for each individual. Calculate the allocation amount according to the following table. Category necessity 65% of income invest Allocation 20% of income play charity 10% of income 5% of income
d) In the display(...) function:
Open with
Using a do-while loop (repeat for 3 times):
Display allocated amount for necessity, invest, play and charity
individuals.
Sample output:
Automated Money Management System
Enter your name
Enter your age
Enter your monthly nett income : RM 59es
: Chan
: 39
Enter your name
Enter your age
Enter your monthly nett income
: Ching
: 44
: RM 7706
Enter your name
Enter your age
Enter your monthly net
: Cindy
: 47
: RM 9001
income
Chan, your salary should be allocated as follows:
[1] Necessity Account
[2] Invest Account
[3] Play Account
[4] Charity Account
: RM 3840.20
: RM 1181.6e
: RM 590.80
: RM 295.40
Ching, your salary should be allocated as follows:
[1] Necessity Account
[2] Invest Account
[3] Play Account
[4] Charity Account
: RM see8.9e
: RM 154120
: RM 770.60
: RM 385.30
Cindy, your salary should be allocated as follows:
[1] Necessity Account
[2] Invest Account
[3] Play Account
[4] Charity Account
: RM 5850.65
: RM 1800, 20
: RM 90e.10
: RM 450.es
File Report.txt before (top) and after (bottom) execution:
|Report - Notepad
File Edit Format View Help
Benji
Belinda 27
21
2257.00 1467.05 451.40
225.70
112.85
3577.00 2325.05 715.40
357.70 178.85
Report - Notepad
File Edit Format View Help
Benji
Belinda 27
21
2257.00 1467.05 451.40
225.70
112.85
3577.00 2325.05 715.40
357.70
178.85
5908.00 3840.20 1181.60 590.80
Chan
Ching
Cindy
39
295.40
385.30
+.05
44
7796.00 5008.90 1541.20 770.60
47
900 Page 5860.ds
6 00.20 900
Transcribed Image Text:d) In the display(...) function: Open with Using a do-while loop (repeat for 3 times): Display allocated amount for necessity, invest, play and charity individuals. Sample output: Automated Money Management System Enter your name Enter your age Enter your monthly nett income : RM 59es : Chan : 39 Enter your name Enter your age Enter your monthly nett income : Ching : 44 : RM 7706 Enter your name Enter your age Enter your monthly net : Cindy : 47 : RM 9001 income Chan, your salary should be allocated as follows: [1] Necessity Account [2] Invest Account [3] Play Account [4] Charity Account : RM 3840.20 : RM 1181.6e : RM 590.80 : RM 295.40 Ching, your salary should be allocated as follows: [1] Necessity Account [2] Invest Account [3] Play Account [4] Charity Account : RM see8.9e : RM 154120 : RM 770.60 : RM 385.30 Cindy, your salary should be allocated as follows: [1] Necessity Account [2] Invest Account [3] Play Account [4] Charity Account : RM 5850.65 : RM 1800, 20 : RM 90e.10 : RM 450.es File Report.txt before (top) and after (bottom) execution: |Report - Notepad File Edit Format View Help Benji Belinda 27 21 2257.00 1467.05 451.40 225.70 112.85 3577.00 2325.05 715.40 357.70 178.85 Report - Notepad File Edit Format View Help Benji Belinda 27 21 2257.00 1467.05 451.40 225.70 112.85 3577.00 2325.05 715.40 357.70 178.85 5908.00 3840.20 1181.60 590.80 Chan Ching Cindy 39 295.40 385.30 +.05 44 7796.00 5008.90 1541.20 770.60 47 900 Page 5860.ds 6 00.20 900
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education