March 24th, 2013, 10:37 AM

before u had (r/12)^m, now u have (1+r/12)^m. You can figure the rest out for yourself i guess.
March 24th, 2013, 10:43 AM

ok but if you look at my formula in the code isnt written correctly?? I dont see what your saying I think I already applied that in the code, if im wrong please show me where
March 24th, 2013, 10:46 AM

[code]
double monthlyPayment= ( ((housePrice  downPayment) * (annualInterestRate/12)) /((1(1+Math.pow(annualInterestRate/12, numberofPayments)))));
/code
i dont know how to fix this please help i obviously dont know how to implement what your saying
March 24th, 2013, 10:47 AM

Originally Posted by Life_Student
ok but if you look at my formula in the code isnt written correctly?? I dont see what your saying I think I already applied that in the code, if im wrong please show me where
In your code:
Code:
(1+Math.pow(annualInterestRate/12, numberofPayments))
that means (1+(r/12)^m), but u need (1+r/12)^m. The 1+ must go from outside the pow, into the first argument.
March 24th, 2013, 10:53 AM

ok i moved it but
i dont think its right i dont know what to do this is like step three of like 30 and im stuck for over three hours now.
heres the code now
Code:
import java.util.Scanner;
public class Project1 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter the price of the house: ");
double housePrice = input.nextDouble();
System.out.println("Enter the down payment: ");
double downPayment = input.nextDouble();
System.out.println("Enter the annual interest rate: ");
double annualInterestRate = input.nextDouble();
System.out.println("Enter the number of payments: ");
double numberofPayments = input.nextDouble();
double monthlyPayment= ( ((housePrice  downPayment) * (annualInterestRate/12)) /((1(1+(Math.pow(annualInterestRate/12, numberofPayments))))));
System.out.println( "The price of the house is: " + housePrice);
System.out.println( "Your down payment is :" + downPayment);
System.out.println( "Your annual interest rate is :" + annualInterestRate);
System.out.println( "Your number of payments are :" + numberofPayments);
System.out.println( "Your monthly payment is :" + monthlyPayment);
}
}
please check, why still negative numbers??
March 24th, 2013, 11:47 AM

Originally Posted by Life_Student
please check, why still negative numbers??
cause you didnt change anything in the calculation. Try splitting the formula up into small parts. first calculation each stuff within parenthesis, than combine the partial results together.
March 24th, 2013, 11:57 AM

ok i split up into a top and a bottom equation they seem to run correctly but the bottom returns a negative which makes the whole number negative.
heres the code
Code:
import java.util.Scanner;
public class Project1 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter the price of the house: ");
double housePrice = input.nextDouble();
System.out.println("Enter the down payment: ");
double downPayment = input.nextDouble();
System.out.println("Enter the annual interest rate: ");
double annualInterestRate = input.nextDouble();
System.out.println("Enter the number of payments: ");
double numberofPayments = input.nextDouble();
double tempTop = ((housePrice  downPayment) * (annualInterestRate/12));
double tempBottom = ((1(1+(Math.pow(annualInterestRate/12, numberofPayments)))));
double monthlyPayment = (tempTop / tempBottom);
System.out.println( "The price of the house is: " + housePrice);
System.out.println( "Your down payment is : " + downPayment);
System.out.println( "Your annual interest rate is :" + annualInterestRate);
System.out.println( "Your number of payments are: " + numberofPayments);
System.out.println( "Your monthly payment is: " + monthlyPayment);
System.out.println( "");
System.out.println( "Top of equation equals: " + tempTop);
System.out.println( "Bottom of equation equals: " + tempBottom);
}
}
March 24th, 2013, 12:01 PM

ok one last time:
ur code (1+Math.pow(....)) means (1+((r/12)^m)), but in ur formula it states (1+r/12)^m
If u dont see the difference between the two equations, i cant help you, sorry. i am not here to do ur assignments.
March 24th, 2013, 12:09 PM

i see the difference but i dont know how to apply it to that line of code
Code:
double tempTop = ((housePrice  downPayment) * (annualInterestRate/12));
double tempBottom = ((1(1+(Math.pow(annualInterestRate/12, numberofPayments)))));
double monthlyPayment = (tempTop / tempBottom);
I broke the problem up a bit can u please show me what you mean I dont know how to put that in code!Please!!
March 24th, 2013, 12:14 PM

Originally Posted by Life_Student
I broke the problem up a bit can u please show me what you mean I dont know how to put that in code!Please!!
I am not going to do ur assignment.
i already said: a^b in code is Math.pow(a,b), (something)^(anotherthing) is therefore Math.pow(something,anotherthing).
March 24th, 2013, 12:17 PM

you mean :
double tempBottom = ((1(1+Math.pow(annualInterestRate/12, numberofPayments))));
??
March 24th, 2013, 12:26 PM

Originally Posted by Life_Student
you mean :
double tempBottom = ((1(1+Math.pow(annualInterestRate/12, numberofPayments))));
??
Yes, this line is wrong. No, you didnt fix it. No, i dont do ur homework. Yes, you need to figure this out on your own or you will never learn.
March 24th, 2013, 12:31 PM

double tempBottom = ((1(Math.pow(1+(annualInterestRate/12), numberofPayments))));
ok it returns a positive now I believe im on the right track.
thanks for your help
March 25th, 2013, 12:25 PM

ok so ive done some work on this code and it all seems to work. I have xhanged it to run loop that figures the downpayment from 0 to 100%of the house price by increments of 10%. it works i think theres a better way to make the increment change but what i did seems to work.
I need to make a loop that shows 11 monthly payments based on the 11 downpayments that i just computed.
Im not sure how to set this loop up because monthly payment is complex i dont know where or how to construct this loop .
heres my current code
Code:
import java.text.DecimalFormat;
import java.util.Scanner;
public class Project1 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter the price of the house: ");
double housePrice = input.nextDouble();
//System.out.println("Enter the down payment: ");
double downPayment = 0;//input.nextDouble(); initial entry of downpayment
System.out.println("Enter the annual interest rate: ");
double annualInterestRate = input.nextDouble();
System.out.println("Enter the number of payments: ");
double numberofPayments = input.nextDouble();
double monthlyPayment = (((housePrice  downPayment) * (annualInterestRate/12))/((1(Math.pow(1+(annualInterestRate/12), numberofPayments)))));
//double formulaBottom = ((1(Math.pow(1+(annualInterestRate/12), numberofPayments))));
//double = (formulaTop / formulaBottom);
DecimalFormat df = new DecimalFormat("0.00");
if (housePrice > 0){
System.out.println( "The price of the house is: $ " + (df.format(housePrice)));
}
else {
System.out.println("Error: Price must be greater than 0! ");
}
for (double myPercent = 0; myPercent <=10; myPercent++ ){
downPayment=((myPercent*.1)*housePrice);
//if (downPayment > 0){ // downpayment if statement
System.out.println( "Your down payment is : $ " + (df.format(downPayment)));
}
//else {
//System.out.println("Error: Price must be greater than 0! ");
//}
if (annualInterestRate < .025 ){
System.out.println("Error: Interest rate too low! ");
}
else if (annualInterestRate > .05 ){
System.out.println("Error: Interest rate too high! ");
}
else {
System.out.println( "Your annual interest rate is : " +(df.format(annualInterestRate)));
}
if (numberofPayments > 0 ){
System.out.println( "Your number of payments are: " + (int)numberofPayments);
}
else {
System.out.println( "Error: must be higher than 0");
}
System.out.println( "Your monthly payment is: $ " + (df.format(monthlyPayment)));
System.exit(0);
}
}
March 25th, 2013, 03:14 PM

Honestly i got no idea what you are trying to do, and your code is not giving me any clue at all...
You are calculating the monthlyPayment in relation to the downpayment before the loop. Than in the loop you set the downpayment to different values but never use them. And in the loop you only print values which doesnt change...