Yeah, it's a bit long though! Sorry, that I wasn't able to explain it clearly.
To qualify for a loan the applicant...
must be 18 years of age or older
and have a credit score ≥ 650
and have income of at least $20,000 or assets of at least $30,000.
If the applicant qualifies for their loan, we must determine how much they may borrow.
First, we will use the credit score:
650 to 699 qualifies for $10,000,
700 to 749 qualifies for $20,000,
750 to 799 qualifies for $30,000,
and finally anything 800 or above qualifies for $40,000.
Second, we must determine whether the applicant qualifies for a bonus $10,000 by either being a home owner or having assets of at least $50,000. The bonus is increased to $15,000 if the applicant is both these things and additionally is 40 years of age or older.
Two things to keep in mind for this project.
1) The lines marked as comment out before upload, should be commented out (i.e. put // in front) otherwise MPL tester will not work. The tester expects no output whatsoever besides one of the two outputs described below in bold.
2) Your output for nonqualifiying applicants should be
Disqualified for loan
and your output for qualifying loans should be
Qualified for $X
where X is the dollar amount .
Notice there is no period at the end of the sentences above. You shouldn't have a period either.
As an example, an output for a qualified applicant might be
Qualified for $10000
There should be no formatting for the dollar amount (e.g. just 10000, not 10,000, nor 10000.00 ) That will be true automatically if you store the amount in a variable of type int .
Use the provided code as a starter kit for your program . Remember to comment out the lines indicated before uploading to MPL. (The functions above main are there to get user input. We'll learn more about functions in Chapter 6. )
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
|
#include <iostream>
#include <string >
using namespace std;
bool promptYN(string msg) {
char entered;
cout << msg << endl; // comment out this line before upload
cin >> entered;
return entered == 'y' || entered == 'Y'
}
int promptInt(string msg) {
int number;
cout << msg << endl; // comment out this line before upload
cin >> number;
return number;
}
int main() {
bool homeowner, employed;
int age, income, assets, creditScore;
// 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
// END OF YOUR CODE
return 0;
}
|
The tester verifies that your output is correct for a variety of test cases. For example if the input is
18
20000
10000
650
n
y
Then the expected output is
Qualified for $10000
Test your code outside of MPL with many possible cases (under 18 years old vs over 18 years old, home owner vs non home owner, credit score under 650 vs over 650 etc.). Verify that your program produces the output it should based on what the instructions say. If you verify a sufficient number of test cases outside of MPL, then your program will be accepted when you submit it to MPL.
More test cases to try. (You need to figure out what the output should be.)
17
20000
10000
650
n
y
_________
18
10000
50000
700
n
y
_________
41
20000
10000
650
y
y
________
18
20000
50000
650
n
y
________
18
20000
10000
850
y
y
________
The above is not a sufficient number of cases. There are at least 7 others you should try.