Objectives After this lab assignment, students should be able to: Design modular programs based on specifications Define and call functions with conditional logic Write programs that use functions ● Background A bank uses the following flowchart to determine whether a customer is eligible for a loan. It contains four steps, separated by color. 0 0 0 0 double askAmount() 0 0 double askincome() How much would you like to borrow? cin >> loan if loan < 0 Please enter positive # What is your yearly Income? cin >> income if income < 0 Please enter positive # askLoan() Return type: bool Parameter(s): None askIncome() Return type: double (loan) Parameter(s): None decideLoan() Yes 0 Return type: bool 0 Would you like to take out a loan? START HERE Thanks for visiting the bank! Return type: double (income) Parameter(s): None askAmount() 0 0 Yes/Y/yes/y or No/N/no/n No ● Instructions: You will use the flowchart to design and write a program that uses a function for each step. Write a program named bankloan.cpp that defines and calls the following functions, EXACTLY as specified below: if income <= 10,000 REJECT if income > 10,000 and income < 100,000 if income >= 100,000 ACCEPT bool askLoan() bool decideLoad(double income, double loan) Invalid choice Please enter yes or no if income * 5 >= loan ACCEPT if income * 5 < loan REJECT Parameter(s): double (income), double (loan) When validating the user input for askLoan(), Validate all user input using loops: accept the following user input for each choice: "Yes", "Y", "yes", and "y" returns true "No", "N", "no", and "n" returns false When validating the user input for askIncome()and askAmount(), make sure the input is greater than or equal to 0.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%
Objectives
After this lab assignment, students should be able to:
Design modular programs based on specifications
Define and call functions with conditional logic
Write programs that use functions
●
●
Background
A bank uses the following flowchart to determine whether a customer is eligible for a loan. It
contains four steps, separated by color.
0
0
0
0
0
0
double
askAmount()
0
0
double
askincome()
How much would you
like to borrow?
cin >> loan
if loan < 0
Please enter positive #
What is your yearly
Income?
cin >> income
if income < 0
Please enter positive #
askLoan()
Return type: bool
Parameter(s): None
askIncome)
Yes
Return type: double (loan)
Parameter(s): None
decideLoan()
Would you like to take
out a loan?
START HERE
Thanks for visiting the bank!
Yes/Y/yes/y
or
No/N/no/n
No
Return type: double (income)
Parameter(s): None
askAmount()
0
0
if income <= 10,000
REJECT
if income > 10,000
and income < 100,000
Instructions:
You will use the flowchart to design and write a program that uses a function for
each step. Write a program named bankloan.cpp that defines and calls the
following functions, EXACTLY as specified below:
if income >= 100,000
ACCEPT
bool decideLoad(double income, double loan)
bool askLoan()
Return type: bool
Parameter(s): double (income), double (loan)
Invalid choice
Please enter yes or no
if income* 5 >= loan
ACCEPT
if income * 5 < loan
REJECT
When validating the user input for askLoan(),
Validate all user input using loops: accept the following user input for each choice:
"Yes", "Y", "yes", and "y" returns true
"No", "N", "no", and "n" returns false
When validating the user input for
askIncome and askAmount(), make sure the input is
greater than or equal to 0.
Transcribed Image Text:Objectives After this lab assignment, students should be able to: Design modular programs based on specifications Define and call functions with conditional logic Write programs that use functions ● ● Background A bank uses the following flowchart to determine whether a customer is eligible for a loan. It contains four steps, separated by color. 0 0 0 0 0 0 double askAmount() 0 0 double askincome() How much would you like to borrow? cin >> loan if loan < 0 Please enter positive # What is your yearly Income? cin >> income if income < 0 Please enter positive # askLoan() Return type: bool Parameter(s): None askIncome) Yes Return type: double (loan) Parameter(s): None decideLoan() Would you like to take out a loan? START HERE Thanks for visiting the bank! Yes/Y/yes/y or No/N/no/n No Return type: double (income) Parameter(s): None askAmount() 0 0 if income <= 10,000 REJECT if income > 10,000 and income < 100,000 Instructions: You will use the flowchart to design and write a program that uses a function for each step. Write a program named bankloan.cpp that defines and calls the following functions, EXACTLY as specified below: if income >= 100,000 ACCEPT bool decideLoad(double income, double loan) bool askLoan() Return type: bool Parameter(s): double (income), double (loan) Invalid choice Please enter yes or no if income* 5 >= loan ACCEPT if income * 5 < loan REJECT When validating the user input for askLoan(), Validate all user input using loops: accept the following user input for each choice: "Yes", "Y", "yes", and "y" returns true "No", "N", "no", and "n" returns false When validating the user input for askIncome and askAmount(), make sure the input is greater than or equal to 0.
Sample Output 1
Would you like to take out a loan?
maybe
Invalid choice; please enter yes or no.
Would you like to take out a loan?
Yes
How much would you like to borrow?
45000
What is your yearly income?
15000
Congratulations! Your loan request for $45000 has been
Sample Output 2
Would you like to take out a loan?
y
How much would you like to borrow?
5000000
What is your yearly income?
45000
Sorry! Your loan request for $5000000 has been rejected.
Notes
You MUST properly define and call the four functions. Just because the program works, does
not mean it is properly written
You may NOT use any global variables in your program. You can, however, send arguments to
functions and use their return values
Transcribed Image Text:Sample Output 1 Would you like to take out a loan? maybe Invalid choice; please enter yes or no. Would you like to take out a loan? Yes How much would you like to borrow? 45000 What is your yearly income? 15000 Congratulations! Your loan request for $45000 has been Sample Output 2 Would you like to take out a loan? y How much would you like to borrow? 5000000 What is your yearly income? 45000 Sorry! Your loan request for $5000000 has been rejected. Notes You MUST properly define and call the four functions. Just because the program works, does not mean it is properly written You may NOT use any global variables in your program. You can, however, send arguments to functions and use their return values
Expert Solution
Step 1

Algorithm:

1. Create a bool function called askLoan which will ask the user if they would like to take out a loan and return a boolean value.
2. Create a double function called askAmount which will ask the user how much they would like to borrow and return the value.
3. Create a double function called askIncome which will ask the user what their yearly income is and return the value.
4. Create a bool function called decideLoan which takes two double parameters, income and loan, and returns a boolean value.
5. In main, create a boolean variable called wantsLoan and assign it to the return value of askLoan.
6. If wantsLoan is false, print out an appropriate message and return 0.
7. Else, create a double variable called loan and assign it to the return value of askAmount.
8. Create a double variable called income and assign it to the return value of askIncome.
9. Create a boolean variable called isApproved and assign it to the return value of decideLoan.
10. If isApproved is true, print out an appropriate message.
11. Else, print out an appropriate message.
12. Return 0.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education