ello, Can someone please help me with this code. Its adding another line to each year.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Hello,
Can someone please help me with this code. Its adding another line to each year.
Thank you for your assistance

 

 

# title
print("Investment Report")
print()
# get numbers from the user about the investment
starting_balance = float(input("Enter the investment amount: $"))
years = int(input("Enter the number of years: "))
rate = int(input("Enter the interest rate as a %: "))
interest = 0
total_interest = 0.0
# convert the rate to a decimal number
rate = rate / 100
# format the headings of our report
print("=" * 70)
print("{:5} {:>20} {:>20} {:>20}".format("Year", "Starting balance", "Interest amount", "Ending balance"))
print("=" * 70)
# initialize the accumulator for the interest

# compute and display results for each year
for each_year in range(1, years+1):
print(each_year, end=" ")
print(starting_balance, end=" ")
interest = round((starting_balance*rate),2)
total_interest += interest
print(interest, end=" ")
starting_balance = round(starting_balance + interest,2)
print(starting_balance, end=" ")
print()
# calculate the interest starting balance*rate
# calculate the ending balance by adding the starting balance to interest
print("{:5} {:>20.2f} {:>20.2f} {:>20.2f}".format(each_year, starting_balance, interest, starting_balance+interest))
# replace the starting balance with the ending balance (using = sign)
# total_interest += interest amount (that I calculated earlier)

# Display the totals for the period
print("-" * 70)
print("Total balance ", "{:27.2f}".format(2850)) # you would replace the number with the ending balance variable
print("Total interest amount earned: ", "{:11.2f}".format(350)) # you would replace the number with the actual total interest calculated
print("-" * 70)

**Interest Calculation Table**

**User Input:**
- **Number of years:** 3
- **Interest rate:** 5%

| Year | Starting Balance | Interest Amount | Ending Balance |
|------|------------------|-----------------|----------------|
| 1    | 2500.00          | 125.00          | 2625.00        |
| 1    | 2625.00          | 125.00          | 2750.00        |
| 2    | 2625.00          | 131.25          | 2756.25        |
| 2    | 2756.25          | 131.25          | 2887.50        |
| 3    | 2756.25          | 137.81          | 2894.06        |
| 3    | 2894.06          | 137.81          | 3031.87        |

**Summary:**
- **Total Balance:** $2850.00
- **Total Interest Amount Earned:** $350.00

At the bottom, it states: "Process finished with exit code 0," indicating successful completion of the computation. 

This table illustrates the growth of an initial investment over three years, with interest accrued and added to the balance annually at a 5% rate.
Transcribed Image Text:**Interest Calculation Table** **User Input:** - **Number of years:** 3 - **Interest rate:** 5% | Year | Starting Balance | Interest Amount | Ending Balance | |------|------------------|-----------------|----------------| | 1 | 2500.00 | 125.00 | 2625.00 | | 1 | 2625.00 | 125.00 | 2750.00 | | 2 | 2625.00 | 131.25 | 2756.25 | | 2 | 2756.25 | 131.25 | 2887.50 | | 3 | 2756.25 | 137.81 | 2894.06 | | 3 | 2894.06 | 137.81 | 3031.87 | **Summary:** - **Total Balance:** $2850.00 - **Total Interest Amount Earned:** $350.00 At the bottom, it states: "Process finished with exit code 0," indicating successful completion of the computation. This table illustrates the growth of an initial investment over three years, with interest accrued and added to the balance annually at a 5% rate.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY