In: Computer Science
For this program you will be looking at future tuition at your university. In 2020, the tuition for a full time student is $6,549 per semester, the tuition for a part time student is $3,325. The tuition will be going up for the next 7 years at a rate of 3.5% per year. Write a program using if-else and a loop. Ask the user if they are a full time or part time student, then display the projected semester tuition for the next 7 years. You should display the actual year (2021, 2022, through 2027) and the tuition amount per semester for that year. REMEMBER to write your name through comments in the program, and use comments to explain what your program is doing. Please write the program in "script" mode
We can solve this problem using Python script. To check if the student is full time or part time employee can be decided using an if...else condition and the tuition for seven years can be displayed using a for loop.
SOLUTION
# global variables to store the full time and part time tuition
# ftt - full time tuition
# ptt - part time tuition
ftt = 6549
ptt = 3325
# rate of increase each year
rate = 3.5/100
# function to calculate rise in amount
# this function returns 3.5% increased amount rounded off to two decimal places
def calc_tuition_rise(tuition):
return round(tuition + (tuition * rate), 2)
# function to interact and display tuition
def future_tuition():
current_tuition = 0
year = 2021
# get user input
response = input("Are you full time(ft) or part time(pt) student: ")
# based on user input assign the current tuition value
if response.lower() == "ft" or response.lower() == "full time":
current_tuition = ftt
else:
current_tuition = ptt
# iterate using a for loop and display tuition for seven years
print("Tuition fees per semester for each year as follows:")
for i in range(7):
current_tuition = calc_tuition_rise(current_tuition)
print(f'{year + i}: ${current_tuition}')
# invoke the function
future_tuition()
SCREENSHOT FROM IDE