From 40c9c13167a846c2d7e3113c1460ab0571e63ec6 Mon Sep 17 00:00:00 2001
From: Daniel Moix <dwm69@drexel.edu>
Date: Tue, 1 Oct 2024 10:59:46 -0400
Subject: [PATCH] Week 2 Lecture

---
 cs171/lect02/debug.py |  9 +++++++++
 cs171/lect02/hello.py | 36 +++++++++++++++++++++++++++++++++++-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 cs171/lect02/debug.py

diff --git a/cs171/lect02/debug.py b/cs171/lect02/debug.py
new file mode 100644
index 0000000..0852eb6
--- /dev/null
+++ b/cs171/lect02/debug.py
@@ -0,0 +1,9 @@
+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
diff --git a/cs171/lect02/hello.py b/cs171/lect02/hello.py
index 061448a..da67a45 100644
--- a/cs171/lect02/hello.py
+++ b/cs171/lect02/hello.py
@@ -1 +1,35 @@
-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)
-- 
GitLab