|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectFindPrincipal
public class FindPrincipal
FindPrincipal.java
Solution for CS 201 HW 1 problem 2
Program to calculate the maximum principal available at a given interest rate, mortgage length, and monthly payment
| Constructor Summary | |
|---|---|
FindPrincipal()
|
|
| Method Summary | |
|---|---|
static double |
find(double mortgage,
double interest,
double years)
Calls findBetween 0 and the upper bound |
static double |
findBetween(double mortgage,
double interest,
double years,
double lo,
double hi)
Finds the ideal principal using a binary search of whether the monthly payment is too high or too low |
static void |
main(java.lang.String[] args)
Calls testFind with mortgage = 1200.00, interst = 7.00, and years = 30.0. |
static void |
testFind(double mortgage,
double interest,
double years)
Prints the output of find in the format find(mortgage, interest, years) = principal |
static double |
upperBound(double mortgage,
double interest,
double years)
Calculates an upper bound for the principal |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FindPrincipal()
| Method Detail |
|---|
public static double find(double mortgage,
double interest,
double years)
mortgage - the monthly mortgage payment that the user can affordinterest - the interest rateyears - the length of the mortgage
public static double findBetween(double mortgage,
double interest,
double years,
double lo,
double hi)
mortgage - the monthly mortgage payment that the user can affordinterest - the interest rateyears - the length of the mortgagelo - the lowest possible principal to examinehi - the hightest possible principal to examine
public static double upperBound(double mortgage,
double interest,
double years)
mortgage - the monthly mortgage payment that the user can affordinterest - the interest rateyears - the length of the mortgage
public static void testFind(double mortgage,
double interest,
double years)
mortgage - the monthly mortgage payment that the user can affordinterest - the interest rateyears - the length of the mortgagepublic static void main(java.lang.String[] args)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||