Question

In: Computer Science

Answer in Python: show all code 3) Modify your code to take as input from the...

Answer in Python: show all code

3) Modify your code to take as input from the user the starting balance, the starting and ending interest rates, and the number of years the money is in the account. In addition, change your code (from problem 2) so that the program only prints out the balance at the end of the last year the money is in the account. (That is, don’t print out the balance during the intervening years.)

Sample Interaction:

Enter starting balance: 1000

Enter starting interest rate: 3

Enter ending interest rate: 5

Enter number of years: 5

Interest rate of 3 %:

Balance after year 5 is $ 1159.27

Interest rate of 4 %:

Balance after year 5 is $ 1216.65

Interest rate of 5 %:

Balance after year 5 is $ 1276.28

problem 2 instruction: to reference for this question:

2) For the last assignment you had to write a program that calculated and displayed the end of year balances in a savings account if $1,000 is put in the account at 6% interest for five years.

The program output looked like this:

Balance after year 1 is $ 1060.0

Balance after year 2 is $ 1123.6

Balance after year 3 is $ 1191.02

Balance after year 4 is $ 1262.48

Balance after year 5 is $ 1338.23

Modify your code so that it displays the balances for interest rates from three to five percent inclusive, in one percent intervals. (Hint: Use an outer loop that iterates on the interest rate, and an inner one that iterates on the year.)

Output:

Interest rate of 3 %:

Balance after year 1 is $ 1030.0

Balance after year 2 is $ 1060.9

Balance after year 3 is $ 1092.73

Balance after year 4 is $ 1125.51

Balance after year 5 is $ 1159.27

Solutions

Expert Solution

Code1:-

bal=int(input("Enter Starting balance: "))
startrate=int(input("Enter Starting interest rate: "))
endingrate=int(input("Enter ending interest rate: "))
years=int(input("Enter number of years: "))
for i in range(startrate,endingrate+1):
print("Interest rate of ",i,"%")
cal=bal
for j in range(1,years+1):
cal=cal+(i/100)*cal
print("Balance after year ",years,"is $",round(cal,2))

Screenshot:-

output:-

Code2:-

bal=int(input("Enter Starting balance: "))
startrate=int(input("Enter Starting interest rate: "))
endingrate=int(input("Enter ending interest rate: "))
years=int(input("Enter number of years: "))
for i in range(startrate,endingrate+1):
print("Interest rate of ",i,"%")
cal=bal
for j in range(1,years+1):
cal=cal+(i/100)*cal
print("Balance after year ",years,"is $",round(cal,2))

Screenshot;-

Output:-


Related Solutions

Hi there, please write code in Python 3 and show what input you used for the...
Hi there, please write code in Python 3 and show what input you used for the program. I've been stuck on this for hours! (1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt) Ex: Enter a sample text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here;...
Python: You will modify the given code to create a guessing game that takes user input...
Python: You will modify the given code to create a guessing game that takes user input and allows you to make multiple guesses. There should also be a loop Use the following attached Sample Code as a guide. There are mistakes in the code!!! #Guessing Game import random number=random.randint(1, another number) print("Hello, CIS 101") print("Let's play a guessing Game!called guess my number.") print("The rules are: ") print("I think of a number and you'll have to guess it.") guess = random.randint(1,...
Take the following code and modify the if(args >= 3) statement to work with a dynamic...
Take the following code and modify the if(args >= 3) statement to work with a dynamic amount of inputs. Example: ./cat file1 file2 file3 file4 filen-1 filen should output a text file that concatenates the files file1 to filen into one file #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) {    char ch;    if (argc ==1)    {        while((ch = fgetc(stdin)) != EOF) fputc(ch, stdout);    }    if (argc == 2)    {   ...
Answer question in Python, show all code: Write a program that calculates and displays the end...
Answer question in Python, show all code: Write a program that calculates and displays the end of year balances in a savings account if $1,000 is put in the account at 6% interest for five years. For this problem, assume interest is calculated annually. (That is, if I put $1000 in a bank account at the beginning of the year, then the balance at the end of the year is $1,000 + $1,000*6%.) You may assume no money is removed...
1. Please use Python 3 programing. 2. Please share your code. 3. Please show all outputs....
1. Please use Python 3 programing. 2. Please share your code. 3. Please show all outputs. Create a GUI Calculator with the following: Title : Calculator Label and Entry box for 1st Number Label and Entry box for 2nd Number Buttons for *, /, +, - Label for result and Displaying the result
In Python b) Modify your program that reads 3 grades from the user (and computes the...
In Python b) Modify your program that reads 3 grades from the user (and computes the average and letter grade) so that it uses a while loop to read the 3 grades. In the loop body, you will just read one grade and update other variables appropriately. The loop header will ensure 3 iterations. c) Modify your program in part b so that it asks the user how many grades there are and uses a while loop to read that...
In this homework, we will write the code that will take an expression (input) from the...
In this homework, we will write the code that will take an expression (input) from the user in infix notation and convert that to corresponding postfix notation and evaluate its value. Task 0: Use the starter code to start. All the needed functions and their functionalities are given in the starter code. Task 1: Complete the startercodeinfixtopostfix.c file Task 2: Complete the startercodeevaluatepostfix.c file Sample Input/Output: (Infix to postfix) Input: (A + B)*C-D*E Output: A B + C * D...
Answer question in Python, show all code 2) Recall the palindrome problem. Write a new program...
Answer question in Python, show all code 2) Recall the palindrome problem. Write a new program that prompts the user for a string and checks to see if that string is a palindrome. For this updated program, input strings may have punctuation marks, spaces, and capitalizations, but these are ignored in the palindrome check. Here are some sample interactions. Please enter a string to check: A man, a plan, a canal: Panama! The string "A man, a plan, a canal:...
Modify the following code to make the input and output look like this. Input 5 Vader...
Modify the following code to make the input and output look like this. Input 5 Vader 1300 Kirk 1250 Adama 1000 Reynolds 1615 Oneill 1470 Output Enter the number of candidates: 5 Enter candidate's name :Vader 1300 Enter votes received :Enter candidate's name :Kirk 1250 Enter votes received :Enter candidate's name :Adama 1000 Enter votes received :Enter candidate's name :Reynolds 1615 Enter votes received :Enter candidate's name :Oneill 1470 Enter votes received : Name Votes Percentage Vader 1300.00 19.59% Kirk...
(CODE IN PYTHON) Program Input: Your program will display a welcome message to the user and...
(CODE IN PYTHON) Program Input: Your program will display a welcome message to the user and a menu of options for the user to choose from. Welcome to the Email Analyzer program. Please choose from the following options: Upload text data Find by Receiver Download statistics Exit the program Program Options Option 1: Upload Text Data If the user chooses this option, the program will Prompt the user for the file that contains the data. Read in the records in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT