# Susanna Pfeffer # CS 87A Spring 2016, Assignment 2 # 3.20.2016 # Requests starting tuition and annual increase rate # Converts string results to float type in order to use for calculations year_one = float(input("Please input your starting tuition for year one: \n")) annual_inc = float(input("Please input the annual increase rate of your tuition: \n")) # Calculates tuition amounts for years 2-4 using increase rate and # previous year's amount year_two = year_one + year_one * annual_inc year_three = year_two + year_two * annual_inc year_four = year_three + year_three * annual_inc # Prints results for years 1-4 and total tuition for all 4 years print("\nYear one tuition: $" + str(format((year_one), '.2f'))) print("Year two tuition: $" + str(format((year_two), '.2f'))) print("Year three tuition: $" + str(format((year_three), '.2f'))) print("Year four tuition: $" + str(format((year_four), '.2f'))) print("\nTotal tuition: $"+str(format((year_one + year_two + year_three + year_four), '.2f')))
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question