QuestionQuestion

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.”.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <cstdlib>
#include <iostream>
using namespace std;

void calcWealth(int & age, int & dependents, long & cash_on_hand, long & amount_owed); // function prototype (reference pass)
bool isRich(int age, int dependents, long cash_on_hand, long amount_owed); // function prototype (value pass)

int main(int argc, char** argv) {

    /*
    * an ‘int’ to represent age and number of dependents
    * a ‘long’ to represent amount of cash on hand and amount owed
    */
    int age;
    int dependents;
    long cash_on_hand;
    long amount_owed;...
$25.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats