I'm working on a program that generates a salary schedule for teachers in a school district, displaying the results in a table format. I've completed the code, but when I test it with values like 20 for starting salary, 2 for annual increase, and 10 for the number of years, I encounter a message stating the calculations are incorrect. I'm uncertain about what I might be overlooking. Here's the relevant code snippet:
```
initial_product = float(input("Enter the starting salary: "))
increase = int(input("Enter the annual '%' increase: "))
years = int(input("Enter the total amount of years: ")) + 1
print()
print('year salary')
print("-----------")
print("%-3d%10.2f" % (1, initial_product))
percent_inc = increase * (1 / 100)
for years in range(2, years):
initial_product += initial_product * percent_inc
final_product = round(initial_product, 2)
print("%-3d%10.2f" % (years, final_product))
```
Any insights on what I might need to adjust?
5 Answers
Since this is for a class, known feedback can really mess with you. Have you checked if the rounding method aligns with what’s expected? I think there’s a chance those later calculations should round differently; for example, adjusting the rounding from the 5th row onward to show an answer that decreases by .01 might be what’s needed. I'm stuck on how to achieve that!
It sounds like the error message you're receiving might not actually be coming from your own code. Are you using any sort of automated testing framework that might be checking the output against expected values?
Check to see if any test cases are working. Are you confident that your output is indeed correct? If your code is being graded by some automated system, sometimes the expected output format matters. For example, the header "year salary" might need to be formatted as "YEARLY SALARY" or something specific!
I noticed a potential issue with your loop variable. You have `years = int(input("Enter the total amount of years: ")) + 1` but later in the loop you use `for years in range(2, years):`. This could be causing confusion — try changing it to `for year in range(...)` instead.
Have you tried using a debugger in your IDE? It can help you track the values of your variables as the code runs. You can typically just hover over variables to see their current state, which might shed some light on where things go wrong.

I think the output looks correct since it passes two tests, but I’m unsure about my logic. Different inputs might yield unexpected results. So I really need help figuring out if there's a logical error.