Loan Program Code
Why is my code for more than 6 inputs when I only have 6 inputs set?
I'm only allowed to change lines 34-57, the rest was given.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#include <iostream>
#include <string>
using namespace std;
bool promptYN(string msg)
{
char entered;
cout << msg << endl; // in front
cin >> entered;
return entered == 'y' || entered == 'Y';
}
int promptInt(string msg)
{
int number;
cout << msg << endl; // in front
cin >> number;
return number;
}
int main()
{
bool homeowner, employed;
int age, income, assets, creditScore, money;
// Do not rearrange this prompt order.
age = promptInt("Age: ");
income = promptInt("Income: ");
assets = promptInt("Assets: ");
creditScore = promptInt("Credit Score: ");
homeowner = promptYN("Home Owner [yn]: ");
employed = promptYN("Employed [yn]: ");
// BEGINNING OF YOUR CODE
money = 0;
cin >> age >> income >> assets >> creditScore >> homeowner >> employed;
if ((age >= 18 && creditScore >= 650 && income >= 20000) || (age >= 18 && creditScore >= 650 && assets >= 30000))
if (creditScore >= 650 && creditScore <= 699)
money += 10000;
else if (creditScore >= 700 && creditScore <= 749)
money += 20000;
else if (creditScore >= 750 && creditScore <= 799)
money += 30000;
else if (creditScore >= 800)
money += 40000;
if (homeowner == 'y' || assets >= 50000)
{
money += 10000;
cout << "Qualified for $" << money;
}
else if (homeowner == 'y' && assets >= 50000 && age >= 40)
{
money += 15000;
cout << "Qualified for $" << money;
}
else
cout << "Disqualified for loan";
// END OF YOUR CODE
return 0;
}
|
Last edited on
Nevermind, I figured it out, haha. It's a bit silly but it did it by default. I didn't need a cin.
Topic archived. No new replies allowed.