146k views
4 votes
In Python please:

Teachers in most school districts are paid on a schedule that provides a salary based on their number of years of teaching experience.
For example, a beginning teacher in the Lexington School District might be paid $30,000 the first year. For each year of experience after this first year, up to 10 years, the teacher receives a 2% increase over the preceding value.
1. Write a program that displays a salary schedule, in tabular format, for teachers in a school district. The inputs are:
the starting salary, the percentage increase, and the number of years in the schedule.
Each row in the schedule should contain the year number and the salary for that year.
An example of the program input and output is shown below:
Enter the starting salary: $30000
Enter the annual % increase: 2
Enter the number of years: 10
Year Salary
-------------
1 30000.00
2 30600.00
3 31212.00
4 31836.24
5 32472.96
6 33122.42
7 33784.87
8 34460.57
9 35149.78
10 35852.78

User Gcas
by
5.0k points

1 Answer

4 votes

Answer:

Here is the python code:

StartingSal = int(input("Enter the starting salary: "))

AnnualIncrease = (int(input("Enter the annual % increase: ")) / 100)

Years = int(input("Enter the number of years: "))

for count in range(1,Years+1):

print("Year ", count, " Salary: ", StartingSal*((1+AnnualIncrease)**(count-1)))

Step-by-step explanation:

This program prompts the user to enter starting salary, percentage increase in salary per year and number of years.

The for loop has range function which is used to specify how many times the salaries are going to be calculated for the number of years entered. It starts from 1 and ends after Years+1 means one value more than the year to display 10 too when user inputs 10 days.

The year and corresponding salary is displayed in output. At every iteration the starting salary is multiplied by annual percentage increase input by user. Here count is used to count the number of salaries per year, count-1 means it will start from 30000.

User Nwaltham
by
4.7k points