Question

*********************C++ program*********************** ( I have tried to write this code in c++ atleast 10 and I...

*********************C++ program***********************

( I have tried to write this code in c++ atleast 10 and I cant get the outputs to print correctly)

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.

example of outputs

_________________________________________________

-- 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%

________________________________________________________

-- 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.

___________________________________________________

-- 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%

____________________________________________________________

-- 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.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

In case of any query do comment. Please rate answer as well, Thanks

Code:

#include <iostream>

using namespace std;

int main()
{
int score;
char discharged, bankruptcy;
double rate=0.0;
  
cout << "----------------------------------------------------------------" << endl;
cout << "-- Thank you for applying for our loan --" << endl;
//user input for score and bankruptcy
cout <<"What is your credit score? ";
cin >>score;
  
cout << "Have you had a bankruptcy? ";
cin >> bankruptcy;
  
//if bankruptcy is yes
if(bankruptcy =='y')
{
//then ask for the status
cout << "Has your bankruptcy been discharged? " ;
cin >>discharged;
  
//if not discharged then application is denied and return
if(discharged == 'n'){
cout <<"Unfortunately, your application has been denied." <<endl <<"You may apply again in 6 months." <<endl;
return 0;
}
}
  
//condition to check however, the user has not had a bankruptcy, or the user had a bankruptcy and it has been discharged
if((bankruptcy =='n') || (bankruptcy =='y' && discharged=='y'))
{
//IF-ELSE-IF to check for rate
if(score < 650)
{
cout <<"Unfortunately, your application has been denied." << endl <<"You may apply again in 6 months." <<endl;
return 0;
}
else if(score <= 720)
rate =3.5;
else if(score <=850)
rate =1.5;
  
if(discharged == 'y')
rate +=3.0;
}
  
//If you are here your application is approved. Display the output
cout << "Your application has been APPROVED! Your rate is " << rate << "%" <<endl;

return 0;
}

==============screen shot of the code ========

Output:

Add a comment
Know the answer?
Add Answer to:
*********************C++ program*********************** ( I have tried to write this code in c++ atleast 10 and I...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Trying to write this program using c language using functions, pointers and loops. "al 67% 1...

    Trying to write this program using c language using functions, pointers and loops. "al 67% 1 1 :14 AM importanu Name your TIies HW2 firstlastname.c Develop a solution to the following problem: A financial institution will only accept loan applications if the following conditions are met: The applicant must own his/her home with no mortgage payment and -The applicant must have a total annual household income of no less than $45000.00. The applicant must have a credit score of no...

  • Modular program mathlab: Write a program in Matlab that would continuously ask the user for an...

    Modular program mathlab: Write a program in Matlab that would continuously ask the user for an input between 1 and 6, which would represent the result of rolling a die. The program would then generate a random integer between 1 and 6 and compare its value to the value entered by user. If the user’s die is larger, it should display, “You got it” If the user’s die is smaller, it should display, “Nice try” If the results are the...

  • Write the pseudocode below as a working Python program. Take a screenshot of your code and...

    Write the pseudocode below as a working Python program. Take a screenshot of your code and output and paste into your answer document. User input of ‘y’ or ‘Y’ should cause the loop to continue.    // Constant for the commission rate    // Declare as a global variable    Constant Real COMMISSION_RATE = 0.10     Module main()        // Local variable         Declare String keepGoing = "y"         // Calculate as many commissions         // as needed.         While...

  • Program Requirements ·         The program prompts the user to enter a loan amount and an interest rate....

    Program Requirements ·         The program prompts the user to enter a loan amount and an interest rate. ·         The application calculates the interest amount and formats the loan amount, interest rate, and interest amount. Then, it displays the formatted results to the user. ·         The application prompts the user to continue. ·         The program stops prompting the user for values after taking 3 loan amounts. ·         The application calculates and displays the total loan and interest amount and ends the program Example Output Welcome to...

  • I do not know how to code this. I have tried several times. Instructions CountByAnything.java +...

    I do not know how to code this. I have tried several times. Instructions CountByAnything.java + Modify the CountByFives application so that the user enters the value to count by. Start each new line after 10 values have been displayed. 1 public class CountByAnything 2 { // Modify the code below 4 public static void main(String args[]) { Grading final int START; final int STOP = 500; final int NUMBER_PER_LINE = 10; for(int i = START; i <= STOP; i...

  • COP 2220 Into programming in C(Answer in C, not C++). The question is: Please write the...

    COP 2220 Into programming in C(Answer in C, not C++). The question is: Please write the algorithm for a AppStore programming assignment. The details of the assignment, a sample algorithm, and its outline, are located below. Make the algorithm at least half a page, easy to read, and to understand, how it works. I just want the algorithm, not the programming code, I have that. I only need the ALGORITHM. Thanks for helping me out, I apprieciate it, have a...

  • I need to see the program in C++: You are to write a payroll application for...

    I need to see the program in C++: You are to write a payroll application for a company. You should prompt the user to input two values in the following order. 1. The number of hours they worked. Our company only pays employees for full hours of work and do not count partial hours. Employees are not allowed to round up the time worked. So, 5 would be a valid input, but 5.7 would not be. 2. The hourly rate...

  • C++ programming please Write a program that will display random numbers in order from low to...

    C++ programming please Write a program that will display random numbers in order from low to high. 1. Declare an integer array of size 100. Ask the user how many numbers to work with (n). It can be less than 100. 2. Generate random numbers from 10 to 50. 3. Write the random numbers to an output file named random.dat. Close the file. 4. Open random.dat for input and read the data values into your array. Pass your array to...

  • This C++ Program should be written in visual studio 2017 You are to write a program...

    This C++ Program should be written in visual studio 2017 You are to write a program that can do two things: it will help users see how long it will take to achieve a certain investment goal given an annual investment amount and an annual rate of return; also, it will help them see how long it will take to pay off a loan given a principal amount, an annual payment amount and an annual interest rate. When the user...

  • #PLEASE WRITE THE CODE IN JAVA! THANK YOU IN ADVANCE! Write a program that manages a...

    #PLEASE WRITE THE CODE IN JAVA! THANK YOU IN ADVANCE! Write a program that manages a list of up to 10 players and their high scores in the computer's memory. Use two arrays to manage the list. One array should store the players' names, and the other array should store the players' high scores. Use the index of the arrays to correlate the names with the scores. Your program should support the following features: a. Add a new player and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT