Flow Control 2c

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

  1. Be sure to look at the sample interaction below to help your understanding of these requirements
  2. Declare an integer: int score
  3. Declare the following chars: char discharged, bankruptcy
  4. Declare a double: double rate. Initialize this to 0.0
  5. Ask the user to enter their credit score. Receive the user’s input in score
  6. 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
  7. 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.
  8. If the user has had a bankruptcy and it has been not discharged show a message that the credit application is denied.
  9. 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:
    1. Check the user’s credit score. If their score is below 650, show a message that their application is denied.
    2. Using an if-else-if construct, and if their score is between 650 and 720, set rate to 3.5
    3. Continue the if-else-if construct and if their score is between 721 and 850, set rate to 1.9
    4. Finally, if the user has had a bankruptcy that has been discharged, add 3.0 to the current value of rate
  10. 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