Description
The purpose of this challenge is to use the IF, IF-ELSE-IF and nested IF statements to control program flow. This simulates the credit underwriting process for a loan.
Requirements
- Be sure to look at the sample interaction below to help your understanding of these requirements
- Declare an integer: int score
- Declare the following chars: char discharged, bankruptcy
- Declare a double: double rate. Initialize this to 0.0
- Ask the user to enter their credit score. Receive the user’s input in score
- Ask the user if they have had a bankruptcy. Receive the user’s input as either a ‘y’ or an ‘n’; use the bankruptcy variable to store this input
- Using a nested if statement, if the user responds that they have had a bankruptcy, ask if the bankruptcy has been discharged. Similarly, receive the user’s input as either a ‘y’ or an ‘n’; use the discharged variable to store this input.
- If the user has had a bankruptcy and it has been not discharged show a message that the credit application is denied.
- If, however, the user has not had a bankruptcy, or the user had a bankruptcy and it has been discharged then write a nested if statement as below:
- Check the user’s credit score. If their score is below 650, show a message that their application is denied.
- Using an if-else-if construct, and if their score is between 650 and 720, set rate to 3.5
- Continue the if-else-if construct and if their score is between 721 and 850, set rate to 1.9
- Finally, if the user has had a bankruptcy that has been discharged, add 3.0 to the current value of rate
- If upon determining that the application was approved, display to the user a congratulatory message with their final interest rate.
Sample Interaction / Output
-- Thank you for applying for our loan -- What is your credit score? 720 Have you had a bankruptcy? n Your application has been APPROVED! Your rate is 3.5%
RUN IT AGAIN:
-- Thank you for applying for our loan -- What is your credit score? 580 Have you had a bankruptcy? n Unfortunately, your application has been denied. You may apply again in 6 months.
RUN IT AGAIN:
-- Thank you for applying for our loan -- What is your credit score? 720 Have you had a bankruptcy? y Has your bankruptcy been discharged? y Your application has been APPROVED! Your rate is 6.5%
RUN IT AGAIN:
-- Thank you for applying for our loan -- What is your credit score? 640 Have you had a bankruptcy? y Has your bankruptcy been discharged? n Unfortunately, your application has been denied. You may apply again in 6 months.
LEGEND
PROGRAM OUTPUT
USER ENTRY
FROM INPUT
CATALOG ID: CPP-FLOW0002c
Print Requirements