Amortization Array

  • (2 Pages)
  • +
  • 1
  • 2

29 Replies - 2074 Views - Last Post: 27 August 2011 - 06:06 AM Rate Topic: -----

#1 wifi34  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 53
  • Joined: 13-August 11

Amortization Array

Posted 20 August 2011 - 09:39 AM

import java.util.Scanner;

public class Amortization_Schedule
{
	public static void main (String[] args){
		
	
	 double [] rates ={.0535, .055, .0575};	
	 int n = 360;
	 double i = 0.0575;
	 double a = 200000.00;
	 double r = (1+i/12);
	 double monthlyPayments  = a * ( r - 1 ) / ( 1 - Math.pow(r,-n));
	 
		 
			Scanner keyboard = new Scanner (System.in);
			int number = 1;
			for ( number = 1; number <= 360; number++)
			
			{  double interest = a * ( i/12 );
		      double principal = monthlyPayments - interest ;
		      double balance = a - principal;
				 a = balance;
				
				 System.out.println("  Payment Number: " + number);
				 System.out.print("The monthly Payment Amount is: " );
			    System.out.printf( "%,.2f" , monthlyPayments );
				 System.out.print("  The Interest is: " );
				 System.out.printf( "%,.2f",  interest );
				 System.out.print("  The Principal Payment is: ");
				 System.out.printf( "%,.2f",  principal );
				 System.out.print("  The Balance is: ");
				 System.out.printf( "%,.2f",  balance );
				 
				 if (number % 24 == 0)
					{
					System.out.println();
					System.out.println("  Press Enter To Continue...");
					keyboard.nextLine();
					}
					
					
			}
							 
		
		 }
	
	 
	 }
	 
	 
	 
	 

This code now needs to be put into an array under these conditions,and the conditions are two seperate changes that need to be made the first change is the first one and the second change is the second,which need to be done in two seperate steps. And I am not sure where to start Please help any direction and explanation will be greatly appreciated I am not looking for someone to complete this for me I just need some Guidance, Direction and explanation, because I want to learn java I just need some help because I am very new at java, and am just learning to use it. any help will be greatly appreciated.

Write the program in Java (without a graphical user interface) and have it calculate the payment amount for 3 mortgage loans:

- 7 year at 5.35%
- 15 year at 5.5%
- 30 year at 5.75%

Use an array for the different loans. Display the mortgage payment amount for each loan.


Use an array for the different loans. Display the mortgage payment amount for each loan and then list the loan balance and interest paid for each payment over the term of the loan. Use loops to prevent lists from scrolling off the screen.

This post has been edited by wifi34: 20 August 2011 - 09:42 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Amortization Array

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10803
  • View blog
  • Posts: 40,273
  • Joined: 27-December 08

Re: Amortization Array

Posted 20 August 2011 - 09:46 AM

My post from your last thread:

Quote

Declare the array. You will access the rates from here. Also, a supplemental tutorial on arrays.
double[] rates = {.0535, .055, .0575};



Which part do you not understand? I'm happy to explain some concepts more, but your last thread was removed b/c you were not showing effort.
Was This Post Helpful? 0
  • +
  • -

#3 wifi34  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 53
  • Joined: 13-August 11

Re: Amortization Array

Posted 20 August 2011 - 10:03 AM

I sent you a private message, that explains everything. but what I was asking is can an array be put into the code I already wrote or does the code need to be entirely rewritten? Any help will be greatly appreciated.
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10803
  • View blog
  • Posts: 40,273
  • Joined: 27-December 08

Re: Amortization Array

Posted 20 August 2011 - 12:19 PM

You can use an array quite easily. Look in your code- which variable holds the interest rate (singular) of .0575. How can you choose the rate based on the duration of the loan? *Think* about how it is done logically. Don't just try and throw code at it until you have thought through what you are trying to accomplish.
Was This Post Helpful? 1
  • +
  • -

#5 wifi34  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 53
  • Joined: 13-August 11

Re: Amortization Array

Posted 21 August 2011 - 01:08 AM

import java.util.Scanner;


public class Amortization_Array {

public static void main (String[] args){
			
 double[] rate = {.0535, .055, .0575};	
 int n = 360;
 double i = 0.0575;
 double a = 200000.00;
 double r = (1+i/12);
 double monthlyPayments  = a * ( r - 1 ) / ( 1 - Math.pow(r,-n));
 double[] term = {84, 180, 360};
	 
		Scanner keyboard = new Scanner (System.in);
		int number = 1;
		for ( number = 1; number <= 360; number++)
		
		{  double interest = a * ( i/12 );
	      double principal = monthlyPayments - interest ;
	      double balance = a - principal;
			 a = balance;
			
			 System.out.println("  Payment Number: " + number);
			 System.out.print("The monthly Payment Amount is: " );
		    System.out.printf( "%,.2f" , monthlyPayments );
			 System.out.print("  The Interest is: " );
			 System.out.printf( "%,.2f",  interest );
			 System.out.print("  The Principal Payment is: ");
			 System.out.printf( "%,.2f",  principal );
			 System.out.print("  The Balance is: ");
			 System.out.printf( "%,.2f",  balance );
			 
			 if (number % 24 == 0)
				{
				System.out.println();
				System.out.println("  Press Enter To Continue...");
				keyboard.nextLine();
				}
				
				
		}
						 
	
	 }

 
 }



I initialized the variables and added the term but I am a little confused about where to go from here, Any help will be greatly appreciated.
Was This Post Helpful? 0
  • +
  • -

#6 wifi34  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 53
  • Joined: 13-August 11

Re: Amortization Array

Posted 21 August 2011 - 01:52 AM

import java.util.Scanner;


public class Amortization_Array {

public static void main (String[] args){
	
 double[] n = {84, 180, 360};
 double[] i = {.0535, .055, .0575};	
 double a = 200000.00;
 double r = (1+i/12);
 double monthlyPayments  = a * ( r - 1 ) / ( 1 - Math.pow(r,-n));
 
 
		Scanner keyboard = new Scanner (System.in);
		int number = 0;
		for ( number = 0; number <= 3; number++){
			for (int j = 1; j <= n ; j++)
		
		
		{ double interest = 0;
	      double principal = 0;
	      double balance = a;
			 a = balance;
			
			 System.out.println("  Payment Number: " + number);
			 System.out.print("The monthly Payment Amount is: " );
		     System.out.printf( "%,.2f" , monthlyPayments );
			 System.out.print("  The Interest is: " );
			 System.out.printf( "%,.2f",  interest );
			 System.out.print("  The Principal Payment is: ");
			 System.out.printf( "%,.2f",  principal );
			 System.out.print("  The Balance is: ");
			 System.out.printf( "%,.2f",  balance );
		}
			 
			 if (number % 24 == 0)
				{
				System.out.println();
				System.out.println("  Press Enter To Continue...");
				keyboard.nextLine();
				}
				
				
		}
						 
	
	 }

 
 }



this is the code I have now, but it is giving me errors and I am not sure what they mean, also I cannot find a solution for the errors and am not sure what the problem is. Please help anything will be greatly appreciated!!


Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The operator / is undefined for the argument type(s) double[], int
The operator - is undefined for the argument type(s) double[]
The operator <= is undefined for the argument type(s) int, double[]

at Amortization_Array.main(Amortization_Array.java:11)
Was This Post Helpful? 0
  • +
  • -

#7 wifi34  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 53
  • Joined: 13-August 11

Re: Amortization Array

Posted 21 August 2011 - 02:46 AM

 import java.util.Scanner;
public class Array {


	public static void main(String[] args) {
		double a = 200000.00;
		double[] i = {.0535, .055, .0575};
		int[] n = {84, 180, 360};
		double r = (1+i/12);
		double monthlyPayments  = a * ( r - 1 ) / ( 1 - Math.pow(r,-n));
		 
		 Scanner keyboard = new Scanner (System.in);
	final int SIZE = 3;
	int[] array = new int [SIZE];
	
	int cnt = 0;
	for(cnt = 0; cnt < array.length; cnt++)
	{
		array [cnt] = cnt;
		System.out.print(array[cnt] + "\n");
		double interest = a * ( i/12 );
	      double principal = monthlyPayments - interest ;
	      double balance = a - principal;
			 a = balance;

	     System.out.println("  Payment Number: " + cnt);
		 System.out.print("The monthly Payment Amount is: " );
	     System.out.printf( "%,.2f" , monthlyPayments );
		 System.out.print("  The Interest is: " );
		 System.out.printf( "%,.2f",  interest );
		 System.out.print("  The Principal Payment is: ");
		 System.out.printf( "%,.2f",  principal );
		 System.out.print("  The Balance is: ");
		 System.out.printf( "%,.2f",  balance );
												}
		 if (cnt % 24 == 0)
		 {	System.out.println();
			System.out.println("  Press Enter To Continue...");
			keyboard.nextLine();  }


	    }
	}






These are the most current changes I made but I am still getting errors an am not sure how to resolve them. these are the two individual problems I need to solve... I have been working on this all night and cannot find a solution, because I am very new to java, so any direction and explanation will be greatly appreciated!!


Write the program in Java (without a graphical user interface) and have it calculate the payment amount for 3 mortgage loans:

- 7 year at 5.35%
- 15 year at 5.5%
- 30 year at 5.75%

Use an array for the different loans. Display the mortgage payment amount for each loan.


Use an array for the different loans. Display the mortgage payment amount for each loan and then list the loan balance and interest paid for each payment over the term of the loan. Use loops to prevent lists from scrolling off the screen.

This post has been edited by wifi34: 21 August 2011 - 02:51 AM

Was This Post Helpful? 0
  • +
  • -

#8 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2205
  • View blog
  • Posts: 5,239
  • Joined: 10-September 10

Re: Amortization Array

Posted 21 August 2011 - 03:04 AM

Because you now have 3 different interest rates, you're being asked to calculate 3 different monthly payments. Please - first think about the use of arrays and how they can be useful in a problem where you have 3 different solutions (monthly payments) because you were given 3 different terms (interest rates and lengths of loan) used to calculate the solution. Think about how the monthlyPayments equation will have to change to calculate 3 solutions and how arrays will be used in the equation. Write it down on paper before coding. Come back and *explain* how that will work, no code.

This post has been edited by GregBrannon: 21 August 2011 - 03:06 AM

Was This Post Helpful? 0
  • +
  • -

#9 wifi34  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 53
  • Joined: 13-August 11

Re: Amortization Array

Posted 21 August 2011 - 03:29 AM

View PostGregBrannon, on 21 August 2011 - 03:04 AM, said:

Because you now have 3 different interest rates, you're being asked to calculate 3 different monthly payments. Please - first think about the use of arrays and how they can be useful in a problem where you have 3 different solutions (monthly payments) because you were given 3 different terms (interest rates and lengths of loan) used to calculate the solution. Think about how the monthlyPayments equation will have to change to calculate 3 solutions and how arrays will be used in the equation. Write it down on paper before coding. Come back and *explain* how that will work, no code.

It should calculate the monthly payments for the term of 84 months, interest .0535 for 200,000.00
then
the term of 180 months, interest .055 for 200,000.00
then
the term of 360 months, interest .0575, for 200,000.00
then calculate the interest, balance, and principal for each term
and then display the results for each individual calculation with the changes in Interest, Principal, and balance over the term of 84, 180, and 360
Was This Post Helpful? 0
  • +
  • -

#10 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2205
  • View blog
  • Posts: 5,239
  • Joined: 10-September 10

Re: Amortization Array

Posted 21 August 2011 - 03:49 AM

It sounds like you described 3 different equations that give 3 different answers. Again, in words, how could those 3 equations and 3 solutions be programmed using arrays.
Was This Post Helpful? 0
  • +
  • -

#11 wifi34  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 53
  • Joined: 13-August 11

Re: Amortization Array

Posted 21 August 2011 - 04:26 AM

That I am not sure I don't understand arrays
but each would need to be calculated seperately and output one afte the other and I think the variables would need to be declaired more than once for each but once for each factor. thank's again
Was This Post Helpful? 0
  • +
  • -

#12 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2205
  • View blog
  • Posts: 5,239
  • Joined: 10-September 10

Re: Amortization Array

Posted 21 August 2011 - 04:47 AM

Here's a basic arrays tutorial. Read through that, and see if it helps you understand how arrays can be used to solve the same equation with different terms to get multiple answers.
Was This Post Helpful? 0
  • +
  • -

#13 wifi34  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 53
  • Joined: 13-August 11

Re: Amortization Array

Posted 21 August 2011 - 05:10 AM

View PostGregBrannon, on 21 August 2011 - 04:47 AM, said:

Here's a basic arrays tutorial. Read through that, and see if it helps you understand how arrays can be used to solve the same equation with different terms to get multiple answers.

I thought it would help but it is very complicated and I cannot make sense of it to solve the equation with different terms to get multiple answers. it is a complex code that needs to be put into use for multiple terms to get multiple answers, and I don't know how to insert an array into my origional code to get the multiple answers for the problem I have, it is just not making sense. thank's !!
Was This Post Helpful? 0
  • +
  • -

#14 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2205
  • View blog
  • Posts: 5,239
  • Joined: 10-September 10

Re: Amortization Array

Posted 21 August 2011 - 05:28 AM

Then you need to ask your instructor for help. That's what he/she is for, and he/she needs to know what you're having trouble with in order to help you.

General guidance: If you need help with code that you've written but need help debugging or improving, come back. If you need help with basic programming elements (all basic program statements, including loops, arrays, conditionals, etc.) or simple math, talk to your instructor.
Was This Post Helpful? 1
  • +
  • -

#15 wifi34  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 53
  • Joined: 13-August 11

Re: Amortization Array

Posted 21 August 2011 - 05:31 AM

You're right I'll do that and come back if get stuck again, and Do you know of any good books for java beginners other than java for dummies?

This post has been edited by wifi34: 21 August 2011 - 05:35 AM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2