#16
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    25
    Rep Power
    0
    before u had (r/12)^-m, now u have (1+r/12)^-m. You can figure the rest out for yourself i guess.
  2. #17
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    41
    Rep Power
    2
    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
  4. #18
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    41
    Rep Power
    2
    [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
  6. #19
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    25
    Rep Power
    0
    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.
  8. #20
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    41
    Rep Power
    2
    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??
  10. #21
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    25
    Rep Power
    0
    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.
  12. #22
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    41
    Rep Power
    2
    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);
    		
    		
    	
    	}	
    	}
  14. #23
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    25
    Rep Power
    0
    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.
  16. #24
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    41
    Rep Power
    2
    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!!
  18. #25
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    25
    Rep Power
    0
    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).
  20. #26
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    41
    Rep Power
    2
    you mean :
    double tempBottom = ((1-(1+Math.pow(annualInterestRate/12, -numberofPayments))));
    ??
  22. #27
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    25
    Rep Power
    0
    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.
  24. #28
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    41
    Rep Power
    2
    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
  26. #29
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    41
    Rep Power
    2
    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);
     
     
    	}	
    	}
  28. #30
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    25
    Rep Power
    0
    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...

IMN logo majestic logo threadwatch logo seochat tools logo