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
What is the mode of 18, 18, 15, 18, 18, 24, 21, 21, 24, and 14?<br> 18<br> 18.5<br> 21<br> 22.3
OLga [1]

Answer: 18

Explanation:

7 0
3 years ago
The number 68 is increased to 73. What is the percentage by which the number was increased, to the nearest tenth of a percent?
Ipatiy [6.2K]
Correct answer should be 1.1%
7 0
2 years ago
Read 2 more answers
Write a Python program that uses function(s) for writing to and reading from a file:
swat32

import random

def random_number_file_writer(nums):

   f = open("random.txt", "w")

   i = 0

   while i < nums:

       f.write(str(random.randint(1,500))+"\n")

       i += 1

   f.close()

def random_number_file_reader():

   f = open("random.txt", "r")

   total = 0

   count = 0

   for x in f.readlines():

       total += int(x)

       count += 1

   print("The total of the numbers is "+str(total))

   print("The number of random numbers read from the file is "+str(count))

def main():

   random_number_file_writer(int(input("How many random numbers do you want to generate? ")))

   random_number_file_reader()

main()

I hope this helps!

6 0
3 years ago
A small company has a web server in the office that is accessible from the internet. the ip address 192.168.10.15 is assigned to
vaieri [72.5K]
the ip nat inside source command to link the inside local and inside global addresses

I hope this helps! :)
5 0
3 years ago
To reposition the legend to the left-hand side of a chart, click the _________ button, point to legend, click the right arrow ic
Leona [35]

Answer:

To reposition the legend to the left-hand side of a chart, click the chart elements button, point to legend, click the right arrow icon, and click left. the

Explanation:

Chart Element button is used to add and remove chart elements. It is located in the Charts Layout group on the Chart tools design tab

6 0
1 year ago
Other questions:
  • I plugged my phone up into a charger, the charger sparked and i unplugged my phone and now it wont charge at all, does anyone kn
    13·1 answer
  • _____ is a school-to-work program that provides the student with paid employment, school credit, and grades while participating.
    14·2 answers
  • How do i build a supercomputer.?
    11·1 answer
  • Drag each label to the correct image.
    9·2 answers
  • Ports that are generally used to establish outbound connections are known as ___ ports.
    14·1 answer
  • Write a program that will read two floating point numbers (the first read into a variable called first and the second read into
    13·1 answer
  • What type of formula uses data from multiple worksheets
    6·1 answer
  • Multi-part question:
    13·1 answer
  • Write a Java program that launches 1000 threads. Each thread adds 1 to a variable sum that initially is 0. You need to pass sum
    11·1 answer
  • If a user wants to change one small section of the formatting of a document and leave the rest the same, which
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!