Can anyone plz help me out with the code of the following question.
Thank You !
We want to determine if someone is “rich.” The definition of being rich depends upon a number of factors such as age, number of dependents, amount of debt, etc., as well as other subjective factors. For the purpose of this exercise, we will only look at the amount of cash someone has – in other words, things like houses, cars, vacation homes, boats, art, antiques, baseball cards, etc., don’t count as “cash on hand” but if an individual owes money on these items, it does count against his net worth. For the sake of simplicity, at the conclusion of this exercise, let’s agree that someone with $1 million in cash and no debt is “rich.”
Write a program that incorporates the use of functions:
• In the main() function , display a pleasing banner of your choosing
• From the main function, call a user-defined function calcWealth() which prompts the user for his age, amount of cash on hand, number of dependents, and amount of money owed to creditors. You should use an ‘int’ to represent age and number of dependents but use a ‘long’ to represent amount of cash on hand and amount owed.
• Next, from the main() function, call a user-defined boolean function, isRich(), which accepts as arguments the age, cash on hand, number of dependents, and amount owed. isRich() will calculate the “true cash value” and then determine if someone is rich. Here are the criteria for isRich():
The amount owed must be subtracted from the cash on hand to determine a preliminary “true cash value”
If a person is has no dependents and a true cash value of $1 million or more, he can be considered rich – regardless of age.
If a person is < 40 years old, subtract $150,000 from his true cash value for each dependent (e.g., if a person has three dependents, subtract $450,000)
If a person is 40-50 years old, subtract $75,000 from his true cash value for each dependent
If a person > 50 years old, subtract $25,000 from his true cash value for each dependent
Return the value of ‘true’ to main() is the person’s true cash value >= $1 million; otherwise, return a value of ‘false’
• The main() function receives the boolean value from isRich() and displays a message indicating whether a person is rich or not.
Sample Session:
Please enter your age: 55
Please enter the amount of cash on hand: 1500000
Please enter the amount of dependents you have: 2
Please enter the amount of money you owe: 250000
Congratulations! We consider you as being “rich.”
Please enter your age: 37
Please enter the amount of cash on hand: 1500000
Please enter the amount of dependents you have: 2
Please enter the amount of money you owe: 250000
I am sorry! You are not yet “rich.”