94.6k views
5 votes
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.

Write a program that displays a salary schedule, in tabular format, for teachers in a school district.
The inputs are:

1. Starting salary
2. Annual percentage increase
3. Number of years for which to print the schedule
4. 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 SharpShade
by
4.6k points

1 Answer

4 votes

Answer:

currentSalary = float(input("Enter the initial salary: $"))

raisePercent = float(input("Enter the annual % raise: "))

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

print()

print("Year Salary")

print("-------------")

for k in range(1,noOfYears+1):

print(k,"\t",end="")

print("%.2f"%currentSalary)

currentSalary = currentSalary * (1+raisePercent /100)

Step-by-step explanation:

The Program is developed on Python.

In this program, we define three variables to take inputs-

1. currentSalary for taking the starting salary.

2. raisePercent - for taking the %age increase.

3. noOfYears- for taking the number of years for which we need to calculate the salary.

The Logic for Calculation of salary for given years with the raise %age-

using a Loop starting from 1 to the number of years we multiplying every time the

the %age raise in salary calculated as (1+ %age/100) to the current salary

to get the salary per year then displaying it corresponding to the loop variable.

User Kevin Hirst
by
4.9k points