1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
OverLord2011 [107]
3 years ago
5

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 ha

ve 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:
# declare global constant variables
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
tuition = startingTuition + tuitionRate;
print('Tuition for the year of ' + str(year)+ ' is ' + str(tuition));
Computers and Technology
1 answer:
Alona [7]3 years ago
7 0

Answer:

The correct loop is as follows:

for year in range(starting_tuitionYear, ending_tuitionYear, increment):

   tuition = startingTuition + rate * startingTuition

   startingTuition = tuition

   print('Tuition for the year of ' + str(year)+ ' is ' + str(tuition));

Explanation:

Required

The correction to the attached program

Some variables are not needed; so, I've removed the redundant variables.

The main error in the program is in the loop;

After the tuition for each year has been calculated, the startTuition of the next year must be set to the current tuition

<em>See attachment for complete program</em>

You might be interested in
2. Create a file with the follow integer/string content and save it as fun.txt. 6 fun. 3 hello 10 &lt;&gt; 2 25 4 wow! Write an
Nesterboy [21]

Answer:

see explaination

Explanation:

I made use of python program to solve this.

text file name with fun.txt.

6 fun. 3 hello 10 <> 2 25 4 wow!

Program code:

import re

file = open('fun.txt','r') #for reading file

strings="" #declaring empty string

for k in file:

strings=strings+k #all character in file is storing in strings variable for do operations

pattern = '\s' #for pattern \s is for space

result = re.split(pattern, strings) #split the string with space

for k in range(len(result)): #loop through the list of string

if(k%2) == 0: #checking for integer to time of string

p=int(result[k])

print(result[k+1] *p) #print times of the string(k+1)

Check attachment for output

8 0
3 years ago
According to the narrator of "EPIC 2015," what is the nature of the news in 2015? A. It is fed to a monitor in people's homes an
allochka39001 [22]

D - it is computer generated content tailored to a person's interests.

Explanation:

D

8 0
3 years ago
The information given to you by your teachers is always accurate and should never be questioned. Please select the best answer f
gavmur [86]

Answer:

im trying to find the answer my self :(

Explanation:

.

3 0
3 years ago
what is internet ?? mention five ways one can use the internet profitably. state five disadvantages of the internet.​
rosijanka [135]

The Internet can be best described as network of networks since it connects over 50 million computer worldwide.

3 0
3 years ago
What does SFA software provides tools for
solong [7]
They provide tools for sfa spftware
5 0
3 years ago
Read 2 more answers
Other questions:
  • A (blank) is a special row in an Excel table that provides a selection of
    12·1 answer
  • Your friend sends you a photograph of his son. you want to enlarge the photograph. which program type will you use to make this
    15·1 answer
  • Which of the following is the amount of space available on a screen to display information?
    8·1 answer
  • You store sensitive data on your computer and need to restrict access to this data by others who use your computer. What will yo
    15·1 answer
  • You have recently completed IPAM installation and configuration. You have several each of DHCPservers, DNS servers, and domain c
    6·1 answer
  • marco wants to create a heading that is bold and italic to make it really stand out on his webpage. he's typed in the code
    12·2 answers
  • Calculating mean for even number and use while loop<br>pleas help me ​
    6·1 answer
  • An attribute is a(n)?
    15·2 answers
  • Susan uploads her newly created files on the web server using FTP. What should she ensure while uploading to prevent other users
    9·2 answers
  • Split the worksheet into panes at cell G1.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!