I have been working on this python program for a hour now, and I am trying to fi
ID: 3870603 • Letter: I
Question
I have been working on this python program for a hour now, and I am trying to figure out what I an doing wrong in the loop. I have attached the code and screenshot of my work. I need help to figure out how to loop the rest of the years for a calculation. The calculation has looped the same result for all years.
This is the assignment:
In 2017, the tuition for a full time student is $6,450 per semester. The tuition will be going up for the next 7 years at a rate of 3.5% per year. Write your python program using a loop that displays the projected semester tuition for the next 7 years. You should display the actual year (2018, 2019, through 2024) and the tuition amount per semester for that year.
Here is my code:
C:/Users/o1/Pyc C:UserslolAppDataLocalProgramsPython, Python36-32python.exe Tuition for the year of 2018 is 6675.75 Tuition for the year of 2019 is 6675.75 11 |Tuition for the year of 2020 is 6675.75 Tuition for the year of 2021 is 6675.75 Tuition for the year of 2022 1s 6675.75 Tuition for the year of 2023 is 6675.75 Tuition for the year of 2024 is 6675.75 Process finished with exit code 0 29 chars, 4 line breaks 1:1 CRLF+ UTF-8 aExplanation / Answer
Hi,
I have fixed the issue and highlighted the code changes below.
startingTuition = 6450.00;
starting_tuitionYear = 2018;
ending_tuitionYear = 2025;
increment = 1;
rate = .035;
tuition = 0;
tuitionRate = 0;
#loop for the next 7 years
for year in range(starting_tuitionYear, ending_tuitionYear, increment):
# calculate rate per year
tuitionRate = (rate)*startingTuition;
# add rate per year to the tuition fee
startingTuition = startingTuition + tuitionRate;
print('Tuition for the year of ' + str(year)+ ' is ' + str(round(startingTuition,2)));
Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.