#Interest Rate #This program uses input from the user to calculate the interest on a loan #print the heading print ("Welcome to the Interest Calculator") #While True statement while True: #Get user input for the loan Amount input ("Enter Loan Amount:") #Getting user input for the interest rate input ("Enter Interest Rate:") #Remove $ symbol using replace method loan = interest = loan = loan.replace ("$","").replace (",","") #check if loan amount ends with K if loan.endswith ("K") : #Remove K from loan amount loan = loan.replace ("K","") #Multiply loan amount by 1000 loan = float (loan) * 1000 #Assign the loan as float value loan = float (loan) #Remove from interest interest = interest.replace ("","") #Assign the interest values as float value interest = float (interest) #Calculate the amount amt = (loan * interest)/100 #Print loan amount formatted with 2 decimal places print ("Loan Amount:${0:.2f}".format (loan)) #Print interest rate formatted with 2 decimal places print ("Interest Rate: {0:.2f}$".format (interest)) #Print interest amount formatted with 2 decimal places print ("Interest Amount:${0:.2f}".format (amt)) #Get y/n input for continue ch = input ("Continue? (y/n): ") #If input is n, then break the loop if ch == 'n': #Break statement break #Print the Bye statement print ("Bye!") Python 3.8.2 Shell File Edit Shell Debug Options Window Help Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 202o, 23:03:10) [MSC v.1916 64 bit (AM A D64) ) on win32 Type "help", "copyright", "credits" or "license ()" for more information. >>> ===== RESTART: C:/Users/shell/OneDrive/Desktop/SFC/COP2002/DMV interest.py ===== Welcome to the Interest Calculator Enter Loan Amount:45000 Enter Interest Rate:4.25 Loan Amount:$45000.00 Interest Rate:4.25% Interest Amount:$1912.50 Continue? (y/n) : y Bye! Enter Loan Amount:100000 Enter Interest Rate:3.75 Loan Amount:$100000.00 Interest Rate:3.75% Interest Amount:$3750.00 Continue? (y/n) : n >>> п

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

How do I fix this Python program, so that it does not print "Bye" when program continues but it does print "Bye" when program ends?

#Interest Rate
#This program uses input from the user to calculate the interest on a loan
#print the heading
print ("Welcome to the Interest Calculator")
#While True statement
while True:
#Get user input for the loan Amount
input ("Enter Loan Amount:")
#Getting user input for the interest rate
input ("Enter Interest Rate:")
#Remove $ symbol using replace method
loan =
interest =
loan = loan.replace ("$","").replace (",","")
#check if loan amount ends with K
if loan.endswith ("K") :
#Remove K from loan amount
loan = loan.replace ("K","")
#Multiply loan amount by 1000
loan = float (loan) * 1000
#Assign the loan as float value
loan = float (loan)
#Remove from interest
interest = interest.replace ("","")
#Assign the interest values as float value
interest = float (interest)
#Calculate the amount
amt =
(loan * interest)/100
#Print loan amount formatted with 2 decimal places
print ("Loan Amount:${0:.2f}".format (loan))
#Print interest rate formatted with 2 decimal places
print ("Interest Rate: {0:.2f}$".format (interest))
#Print interest amount formatted with 2 decimal places
print ("Interest Amount:${0:.2f}".format (amt))
#Get y/n input for continue
ch = input ("Continue? (y/n): ")
#If input is n, then break the loop
if ch == 'n':
#Break statement
break
#Print the Bye statement
print ("Bye!")
Transcribed Image Text:#Interest Rate #This program uses input from the user to calculate the interest on a loan #print the heading print ("Welcome to the Interest Calculator") #While True statement while True: #Get user input for the loan Amount input ("Enter Loan Amount:") #Getting user input for the interest rate input ("Enter Interest Rate:") #Remove $ symbol using replace method loan = interest = loan = loan.replace ("$","").replace (",","") #check if loan amount ends with K if loan.endswith ("K") : #Remove K from loan amount loan = loan.replace ("K","") #Multiply loan amount by 1000 loan = float (loan) * 1000 #Assign the loan as float value loan = float (loan) #Remove from interest interest = interest.replace ("","") #Assign the interest values as float value interest = float (interest) #Calculate the amount amt = (loan * interest)/100 #Print loan amount formatted with 2 decimal places print ("Loan Amount:${0:.2f}".format (loan)) #Print interest rate formatted with 2 decimal places print ("Interest Rate: {0:.2f}$".format (interest)) #Print interest amount formatted with 2 decimal places print ("Interest Amount:${0:.2f}".format (amt)) #Get y/n input for continue ch = input ("Continue? (y/n): ") #If input is n, then break the loop if ch == 'n': #Break statement break #Print the Bye statement print ("Bye!")
Python 3.8.2 Shell
File Edit Shell Debug Options Window Help
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 202o, 23:03:10)
[MSC v.1916 64 bit (AM A
D64) ) on win32
Type "help", "copyright", "credits" or "license ()" for more information.
>>>
===== RESTART: C:/Users/shell/OneDrive/Desktop/SFC/COP2002/DMV interest.py
=====
Welcome to the Interest Calculator
Enter Loan Amount:45000
Enter Interest Rate:4.25
Loan Amount:$45000.00
Interest Rate:4.25%
Interest Amount:$1912.50
Continue? (y/n) : y
Bye!
Enter Loan Amount:100000
Enter Interest Rate:3.75
Loan Amount:$100000.00
Interest Rate:3.75%
Interest Amount:$3750.00
Continue? (y/n) : n
>>>
п
Transcribed Image Text:Python 3.8.2 Shell File Edit Shell Debug Options Window Help Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 202o, 23:03:10) [MSC v.1916 64 bit (AM A D64) ) on win32 Type "help", "copyright", "credits" or "license ()" for more information. >>> ===== RESTART: C:/Users/shell/OneDrive/Desktop/SFC/COP2002/DMV interest.py ===== Welcome to the Interest Calculator Enter Loan Amount:45000 Enter Interest Rate:4.25 Loan Amount:$45000.00 Interest Rate:4.25% Interest Amount:$1912.50 Continue? (y/n) : y Bye! Enter Loan Amount:100000 Enter Interest Rate:3.75 Loan Amount:$100000.00 Interest Rate:3.75% Interest Amount:$3750.00 Continue? (y/n) : n >>> п
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Matrix multiplication
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
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