Created
February 1, 2014 21:20
-
-
Save TrevorBasinger/8759087 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**************************************************************************************************************** | |
* Project5.cpp | |
* Thad H. Crawford | |
* CS225 | |
* Project 5 | |
* | |
* Are we "Rich" Yet? | |
* | |
* Program asks user to input various information and the information is used to determine if the user is "rich" based | |
* on predetermined criteria. | |
* | |
************************************************************************************************************************/ | |
#include <iostream> //for input and output | |
using namespace std; | |
void calcWealth(int * age, long * cash, int * deps, long * debt) | |
{ | |
cout << "Please enter your age: "; | |
cin >> age; | |
cout << "Please enter the amount of cash on hand: "; | |
cin >> cash; | |
cout << "Please enter the amount of dependents you have: "; | |
cin >> deps; | |
cout << "Please enter the amount of money you owe"; | |
cin >> debt; | |
} | |
bool isRich(int age, long cash, int deps, long debt) | |
{ | |
long trueCash; | |
trueCash = cash - debt; | |
if (deps == 0) | |
{ | |
if (trueCash >= 1000000) | |
{ | |
return true; | |
} | |
else | |
return false; | |
} | |
else if (age < 40) | |
{ | |
trueCash = trueCash - (deps * 150000); | |
if (trueCash >= 1000000) | |
{ | |
return true; | |
} | |
else | |
return false; | |
} | |
else if (age > 39 && age < 51) | |
{ | |
trueCash = trueCash - (deps * 75000); | |
if (trueCash >= 1000000) | |
{ | |
return true; | |
} | |
else | |
return false; | |
} | |
else | |
{ | |
trueCash = trueCash - (deps * 25000); | |
if (trueCash >= 1000000) | |
{ | |
return true; | |
} | |
else | |
return false; | |
} | |
} | |
int main() | |
{ | |
//display a "banner" | |
int age; | |
long cash; | |
int deps; | |
long debt; | |
calcWealth(&age, &cash, &deps, &debt); | |
if (isRich(age, cash, deps, debt)) | |
{ | |
cout << "Congratulations! We consider your as being \"rich.\"" << endl; | |
} | |
else | |
{ | |
cout << "I am sorry! You are not yet \"rich.\"" << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment