I NEED HELP! (please and thank you).

I have an assignmet for extra points. I'm lost. Out profesor is not explaining anything and the assignments are NOT what we covered so far (which isn't much). I could use any help I can get. I've been trying to google it and how to use functions and i'm helpless. I heard a lot about this forum, so here I am!

The assignment says: In recent years, college tuition has risen at a national average annual rate of 15%.

a) Write the function definition of this function heather:

def Tuition(current, thisYear, targetYear):

This function takes three arguments: the current tuition, the current year (e.g., 2013) and the target
year (e.g., 2020). It returns the tuition of the target year by repeatedly multiplying the starting tuition
by 1.15 (115 %).

b) Write a main that will repeatedly get the current tuition, current year, and the target year from the
user and display the resulting tuition, until the user enters zero for any of the three values. Test and

c) When your program and function are working correctly, run them with this set of data:

4500.00 2013 2017 (R1 tuition/fees)
2000.00 2013 2019 (State tuition/fees)
12000.00 2013 2027 (mid-range private tuition)
0.0 0 0

please feel free to teach me and give me pointers on how to start working on this. feel fre to email me directly on WaseemAbuRakia@gmail.com

## All 8 Replies

What version of Python are you using?

2.7

Hint ...

``````current = 4500
thisYear = 2013
targetYear = 2017

tuition = current
for year in range(thisYear, targetYear+1):
print(year, tuition)  # test
tuition *= 1.15
``````

I guess my main issue is how to to as for user input within the function! and/or how to invoke it

required user interaction:

Tuition predictions at 15% annual increase

At the ?, enter a tuition, the current year and the target year.
Enter zero in any field to quit.

? nnnnn.nn xxxx yyyy
In yyyy, tuition will be zzzzz.zzz

? nnnnn.nn xxxx yyyy
In yyyy, tuition will be zzzzz.zz

? 0 0 0

You could use a while loop ...

``````# endless loop with exit condition
while True:
current = int(raw_input("Enter current Tuition rate: "))
thisYear = int(raw_input("Enter current year: "))
targetYear = int(raw_input("Enter target year: "))
# exit condition
if current==0 or thisYear==0 or targetYear==0:
break
# now call your function and get result
#newTuition = tuition(current, thisYear, targetYear)
``````

Thank you so much for your help. I'm supposed to use functions. as in defining a main one and another function, while making the program quit if a zero is entered at any time. That's why I'm so confused by the professor. I already had a similar code like yours in mind.

Looks like your teacher wants a more complex input in function main() like this:

``````# endless loop with exit condition
while True:
print("Enter tution rate, current year, target year")
print("in the form nnnnn.nn xxxx yyyy")
data = raw_input("? ")
current, thisYear, targetYear = data.split()
current = float(current)
thisYear = int(thisYear)
targetYear = int(targetYear)
# exit condition
if current==0 or thisYear==0 or targetYear==0:
break
# now call your function and get result
#newTuition = tuition(current, thisYear, targetYear)
``````
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.