Docsity

CS121-Quiz4-Fall2025, Quizzes of Computer Science

Toggle sidebar
bg1
CptS 121 – Program Design and Development
Date Assigned: Fri, Sep 26, 2025 Due Date: Mon, Sep 29, 2025
Take Home: Quiz 4 (15 pts) – Selection Structures & Loops
Using Canvas https://canvas.wsu.edu/, please submit your solution to the correct quiz
folder. Your solution should be a .pdf file with the name <your last name>_quiz4.pdf
and uploaded. To upload your solution, please navigate to your correct Canvas
lab
course space. Select the “Assignments” link in the main left menu bar. Navigate to the
correct quiz submission folder. Click the “Start Assignment” button. Click the “Upload
File” button. Choose the appropriate .pdf file with your solution. Finally, click the
“Submit Assignment” button.
NOTE: The use of gen AI is forbidden for quizzes.
1. (8 pts) Write a function loan_rate() that determines the lowest
interest rate for a car loan. There are three factors that impact
the rate: credit score (a positive whole number), income, and
debt-to-income ratio. The three factors are input parameters into
the function. The function should compute an interest based on
the table below.
Credit Score Income Debt-to-
Income
Ratio
Interest Rate
>= 800 >= $40,000 <= 28% 2.58%
>= 700 >= $30,000 <= 32% 3.64%
>= 650 >= $30,000 <= 36% 5.80%
>= 600 >= $25,000 <= 45% 9.87%
< 600 < $25,000 > 45% Loan declined
For a given interest rate all three factors must be satisfied. For
the last row in the table, only one of the factors must be satisfied
for the loan to be declined. The function must return the lowest
computed interest rate or -1 if the loan is declined.
I wrote my code in Visual Studio. Hope it’s okay.
Instructor: Andrew S. O’Fallon
pf3

Partial preview of the text

Download CS121-Quiz4-Fall2025 and more Quizzes Computer Science in PDF only on Docsity!

Date Assigned: Fri, Sep 26, 2025 Due Date: Mon, Sep 29, 2025 Take Home: Quiz 4 (15 pts) – Selection Structures & Loops Using Canvas https://canvas.wsu.edu/, please submit your solution to the correct quiz folder. Your solution should be a .pdf file with the name _quiz4.pdf and uploaded. To upload your solution, please navigate to your correct Canvas lab course space. Select the “Assignments” link in the main left menu bar. Navigate to the correct quiz submission folder. Click the “Start Assignment” button. Click the “Upload File” button. Choose the appropriate .pdf file with your solution. Finally, click the “Submit Assignment” button. NOTE: The use of gen AI is forbidden for quizzes.

  1. (8 pts) Write a function loan_rate() that determines the lowest interest rate for a car loan. There are three factors that impact the rate: credit score (a positive whole number), income, and debt-to-income ratio. The three factors are input parameters into the function. The function should compute an interest based on the table below. Credit Score Income Debt-to- Income Ratio Interest Rate

= 800 >= $40,000 <= 28% 2.58% = 700 >= $30,000 <= 32% 3.64% = 650 >= $30,000 <= 36% 5.80% = 600 >= $25,000 <= 45% 9.87% < 600 < $25,000 > 45% Loan declined For a given interest rate all three factors must be satisfied. For the last row in the table, only one of the factors must be satisfied for the loan to be declined. The function must return the lowest computed interest rate or -1 if the loan is declined. I wrote my code in Visual Studio. Hope it’s okay.

Date Assigned: Fri, Sep 26, 2025 Due Date: Mon, Sep 29, 2025

  1. (7 pts) Construct a C code fragment using a for() loop, which finds the smallest integer in the range 1 - n. Where n is an