Skip to content
Snippets Groups Projects
Commit 40c9c131 authored by Daniel Moix's avatar Daniel Moix
Browse files

Week 2 Lecture

parent 9e95bf1f
No related branches found
No related tags found
No related merge requests found
def addThese(a, b):
return a + b
# print(addThese(22, 7))
import hello
import math
print(hello.totalCollegeTuition(10000, 2))
\ No newline at end of file
print("Hello CS 171")
def totalCollegeTuition(costPerTerm, numTerms):
return costPerTerm * numTerms
def loanPayment(principal, rate, numMonths):
rate = rate / 12
onePlus = ((1 + rate) ** numMonths)
numerator = rate * onePlus
denominator = onePlus - 1
payment = principal * (numerator / denominator)
return payment
def yearsToRepay(amountOwed, hourlyWage):
hours = amountOwed / hourlyWage
weeks = hours / 40
years = weeks / 52
return years
if __name__ == "__main__":
uniName = input("Name of university:\n")
costPerTerm = float(input("How much does one term cost?\n"))
numTerms = int(input("How many terms are required to graduate?\n"))
apr = float(input("What is the annual percentage rate? (ex: 0.055)\n"))
numYears = int(input("How many year will you take to pay it back?\n"))
months = numYears * 12
totalTuition = totalCollegeTuition(costPerTerm, numTerms)
payment = loanPayment(totalTuition, apr, months)
print("Your total tuition will be", totalTuition)
print("Your monthly payment will be", payment)
totalLoanCost = payment * months
print("Your sum of payments is", totalLoanCost)
years = yearsToRepay(totalLoanCost, 7.25)
print("You would need to work", years, "years at minimum wage to repay your loan for attending", uniName)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment