-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoublePractice.groovy
More file actions
35 lines (29 loc) · 1.06 KB
/
doublePractice.groovy
File metadata and controls
35 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
print "Please enter total amount borrowed: "
String str = System.console().readLine()
double amountBorrowed = Double.parseDouble(str)
print "Please enter total years left on your mortgage: "
str = System.console().readLine()
double yearsLeft = Double.parseDouble(str)
print "Please enter interest rate: "
str = System.console().readLine()
double interestRate = Double.parseDouble(str)
double totalMoney(double amountBorrowedX, double interestRateX){
double x = (interestRateX/100)+1
int y = amountBorrowedX*x
return y
}
double a = totalMoney(amountBorrowed, interestRate)
double yearlyCost(double totalMoneyX, double yearsLeftX){
int x = totalMoneyX/yearsLeftX
return x
}
double b = yearlyCost(a , yearsLeft)
double interestPayOff(double amountBorrowedX, double yearlyCostX, double aX){
int x = aX - amountBorrowedX
int y = x/yearlyCostX
return y
}
double c = interestPayOff(amountBorrowed, b, a)
println "Your amount to be paid is: " + a
println "Your yearly cost is " + b
println "The number of years before your interest is paid off is: " + c