For Programmers: Free Programming Magazines  


Home > Archive > Java Help > April 2004 > newbie needing major help









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author newbie needing major help
NOAH FENLEY JR

2004-04-27, 4:12 am

I have made a mistake and I am hoping someone here can bail me out. I need to turn the code below into a GUI interface and quick. TIA please help\

Code:



//Noah Fenley
//POS406 w 4 personal assignment
//
//
import java.text.*;
public class w5
{//open
public static void main(String[] args)
{//open
wk5ClassSupport[] scenarios;//create array
scenarios = new wk5ClassSupport[3];
for (int x=0; x < 3; x++)//avoid empty statement
scenarios[x] = new wk5ClassSupport();

//array values
scenarios[0].setyears(7);
scenarios[1].setyears(15);
scenarios[2].setyears(30);
scenarios[0].setRate(5.35);
scenarios[1].setRate(5.5);
scenarios[2].setRate(5.75);


for (int x=0;x<3;x++)//enter loan amount for each loan array
scenarios[x].setLoan(200000.00);
for (int x =0; x<3; x++)
{//display after calculations--Open
scenarios[x].calculateDisplay();//run the calculate section of wk3Class
System.out.println("-------------------------------------------------");
}//Close
}//Close
}//close

And the support class

//Noah Fenley
//Some of the code from w 3 has been commented out. I prefer to keep the code intact
//just in case I need to return to it for reference.

import java.text.*;
public class wk5ClassSupport {//open
//public static void main(String[] args)throws InterruptedException {
//Constants
private double Loan; // Loan amount
private double Rate;
private int years;
// //Number of total payments 12 months X 30 years

public void setyears(int passedValue)//years to be passed from w4 class
{//open
years = passedValue;
}//close
public void setRate(double passedValue)//Rate to be passed
{//open
Rate = passedValue;
}//close
public void setLoan(double passedValue)//loan amount to be passed
{//open
Loan = passedValue;
}//close
public void calculateDisplay()//display to be passed
{//open

//Variables
double pymt = 0.0;
double intPymt = 0.0;// Interest payments initial value
double remainingBalance = Loan;
double prinPymt = 0.0;// Principle payment
//double mpr = Rate; //APR divided by 100 to get % then 12 for the months in a year
int pymtNum = years * 12;
double Apr = Rate/100/12;//useless now, but helped during debugging

int c = 0; // counter

DecimalFormat twoDecimalPlaces = new DecimalFormat("###,###,###.00");// formatter for printing
System.out.println("Amount Financed: $ " + twoDecimalPlaces.format(Loan));// Show The Loan Total
System.out.println("Total number of payments: " + years *12);// Show number of payments
pymt = Loan * (Math.pow(((1-(Math.pow((1 + Apr),-pymtNum)))/Apr), -1)); // Payment
System.out.println("Monthly Payment :$ " + twoDecimalPlaces.format(pymt));
System.out.println("Loan Term In Years:"+years );//Show laon years
System.out.println("APR: " + Rate + "%");// Show APR


//previous info not used in this class anymore.


//Thread.sleep(3000); //pause for 3 seconds
for (int x = 1; x < (pymtNum + 1); x++) {
intPymt = remainingBalance * Rate/100/12;//interest paid monthly
prinPymt = pymt - intPymt;//monthly principle
remainingBalance = remainingBalance - prinPymt;// remaining balance
c++; //display 12 payments
System.out.println("Payment" + x + "\t"+ "Interest Paid: $"+ twoDecimalPlaces.format(intPymt)+ "\tPrinciple: $" + twoDecimalPlaces.format(prinPymt)+ "\t Balance: $" + twoDecimalPlaces.format(remainingBalance));
if (c == 12) {//show 12 payments since there are 12 a year
//Thread.sleep(5000);//pause for 5 seconds
c = 0;
}
}
}
}






--
NGF74

Ben Aroia

2004-04-30, 1:22 pm

"NOAH FENLEY JR" <ngf74@advantexmail.net> wrote in message news:<108p7qcb316bnad@corp.supernews.com>...
> I have made a mistake and I am hoping someone here can bail me out. I
> need to turn the code below into a GUI interface and quick. TIA please
> help\
>
> Code:
>
>
>
> //Noah Fenley
> //POS406 w 4 personal assignment
> //
> //
> import java.text.*;
> public class w5
> {//open
> public static void main(String[] args)
> {//open
> wk5ClassSupport[] scenarios;//create array
> scenarios = new wk5ClassSupport[3];
> for (int x=0; x < 3; x++)//avoid empty statement
> scenarios[x] = new wk5ClassSupport();
>
> //array values
> scenarios[0].setyears(7);
> scenarios[1].setyears(15);
> scenarios[2].setyears(30);
> scenarios[0].setRate(5.35);
> scenarios[1].setRate(5.5);
> scenarios[2].setRate(5.75);
>
>
> for (int x=0;x<3;x++)//enter loan amount for each loan array
> scenarios[x].setLoan(200000.00);
> for (int x =0; x<3; x++)
> {//display after calculations--Open
> scenarios[x].calculateDisplay();//run the calculate section
> of wk3Class
>
> System.out.println("-------------------------------------------------");
> }//Close
> }//Close
> }//close
>
> And the support class
>
> //Noah Fenley
> //Some of the code from w 3 has been commented out. I prefer to keep
> the code intact
> //just in case I need to return to it for reference.
>
> import java.text.*;
> public class wk5ClassSupport {//open
> //public static void main(String[] args)throws InterruptedException
> {
> //Constants
> private double Loan; // Loan amount
> private double Rate;
> private int years;
> // //Number of total payments 12 months X 30 years
>
> public void setyears(int passedValue)//years to be
> passed from w4 class
> {//open
> years = passedValue;
> }//close
> public void setRate(double passedValue)//Rate to be
> passed
> {//open
> Rate = passedValue;
> }//close
> public void setLoan(double passedValue)//loan amount to
> be passed
> {//open
> Loan = passedValue;
> }//close
> public void calculateDisplay()//display to be passed
> {//open
>
> //Variables
> double pymt = 0.0;
> double intPymt = 0.0;// Interest payments initial value
> double remainingBalance = Loan;
> double prinPymt = 0.0;// Principle payment
> //double mpr = Rate; //APR divided by 100 to get %
> then 12 for the months in a year
> int pymtNum = years * 12;
> double Apr = Rate/100/12;//useless now, but helped
> during debugging
>
> int c = 0; // counter
>
> DecimalFormat twoDecimalPlaces = new
> DecimalFormat("###,###,###.00");// formatter for printing
> System.out.println("Amount Financed: $ " +
> twoDecimalPlaces.format(Loan));// Show The Loan Total
> System.out.println("Total number of payments: " + years *12);// Show
> number of payments
> pymt = Loan * (Math.pow(((1-(Math.pow((1 + Apr),-pymtNum)))/Apr),
> -1)); // Payment
> System.out.println("Monthly Payment :$ " +
> twoDecimalPlaces.format(pymt));
> System.out.println("Loan Term In Years:"+years );//Show
> laon years
> System.out.println("APR: " + Rate + "%");// Show APR
>
>
> //previous info not used in this class anymore.
>
>
> //Thread.sleep(3000); //pause for 3 seconds
> for (int x = 1; x < (pymtNum + 1); x++) {
> intPymt = remainingBalance *
> Rate/100/12;//interest paid monthly
> prinPymt = pymt - intPymt;//monthly principle
> remainingBalance = remainingBalance - prinPymt;//
> remaining balance
> c++; //display 12 payments
> System.out.println("Payment" + x + "\t"+
> "Interest Paid: $"+ twoDecimalPlaces.format(intPymt)+ "\tPrinciple: $" +
> twoDecimalPlaces.format(prinPymt)+ "\t Balance: $" +
> twoDecimalPlaces.format(remainingBalance));
> if (c == 12) {//show 12 payments since there are 12
> a year
> //Thread.sleep(5000);//pause for 5 seconds
> c = 0;
> }
> }
> }
> }

i didn't read all the code but do you want me to turn it into a gui
interface for you? or do you want me to offer sugestions? e-mail me
-Ben
Ben Aroia

2004-04-30, 1:22 pm

"NOAH FENLEY JR" <ngf74@advantexmail.net> wrote in message news:<108p7qcb316bnad@corp.supernews.com>...
> I have made a mistake and I am hoping someone here can bail me out. I
> need to turn the code below into a GUI interface and quick. TIA please
> help\
>
> Code:
>
>
>
> //Noah Fenley
> //POS406 w 4 personal assignment
> //
> //
> import java.text.*;
> public class w5
> {//open
> public static void main(String[] args)
> {//open
> wk5ClassSupport[] scenarios;//create array
> scenarios = new wk5ClassSupport[3];
> for (int x=0; x < 3; x++)//avoid empty statement
> scenarios[x] = new wk5ClassSupport();
>
> //array values
> scenarios[0].setyears(7);
> scenarios[1].setyears(15);
> scenarios[2].setyears(30);
> scenarios[0].setRate(5.35);
> scenarios[1].setRate(5.5);
> scenarios[2].setRate(5.75);
>
>
> for (int x=0;x<3;x++)//enter loan amount for each loan array
> scenarios[x].setLoan(200000.00);
> for (int x =0; x<3; x++)
> {//display after calculations--Open
> scenarios[x].calculateDisplay();//run the calculate section
> of wk3Class
>
> System.out.println("-------------------------------------------------");
> }//Close
> }//Close
> }//close
>
> And the support class
>
> //Noah Fenley
> //Some of the code from w 3 has been commented out. I prefer to keep
> the code intact
> //just in case I need to return to it for reference.
>
> import java.text.*;
> public class wk5ClassSupport {//open
> //public static void main(String[] args)throws InterruptedException
> {
> //Constants
> private double Loan; // Loan amount
> private double Rate;
> private int years;
> // //Number of total payments 12 months X 30 years
>
> public void setyears(int passedValue)//years to be
> passed from w4 class
> {//open
> years = passedValue;
> }//close
> public void setRate(double passedValue)//Rate to be
> passed
> {//open
> Rate = passedValue;
> }//close
> public void setLoan(double passedValue)//loan amount to
> be passed
> {//open
> Loan = passedValue;
> }//close
> public void calculateDisplay()//display to be passed
> {//open
>
> //Variables
> double pymt = 0.0;
> double intPymt = 0.0;// Interest payments initial value
> double remainingBalance = Loan;
> double prinPymt = 0.0;// Principle payment
> //double mpr = Rate; //APR divided by 100 to get %
> then 12 for the months in a year
> int pymtNum = years * 12;
> double Apr = Rate/100/12;//useless now, but helped
> during debugging
>
> int c = 0; // counter
>
> DecimalFormat twoDecimalPlaces = new
> DecimalFormat("###,###,###.00");// formatter for printing
> System.out.println("Amount Financed: $ " +
> twoDecimalPlaces.format(Loan));// Show The Loan Total
> System.out.println("Total number of payments: " + years *12);// Show
> number of payments
> pymt = Loan * (Math.pow(((1-(Math.pow((1 + Apr),-pymtNum)))/Apr),
> -1)); // Payment
> System.out.println("Monthly Payment :$ " +
> twoDecimalPlaces.format(pymt));
> System.out.println("Loan Term In Years:"+years );//Show
> laon years
> System.out.println("APR: " + Rate + "%");// Show APR
>
>
> //previous info not used in this class anymore.
>
>
> //Thread.sleep(3000); //pause for 3 seconds
> for (int x = 1; x < (pymtNum + 1); x++) {
> intPymt = remainingBalance *
> Rate/100/12;//interest paid monthly
> prinPymt = pymt - intPymt;//monthly principle
> remainingBalance = remainingBalance - prinPymt;//
> remaining balance
> c++; //display 12 payments
> System.out.println("Payment" + x + "\t"+
> "Interest Paid: $"+ twoDecimalPlaces.format(intPymt)+ "\tPrinciple: $" +
> twoDecimalPlaces.format(prinPymt)+ "\t Balance: $" +
> twoDecimalPlaces.format(remainingBalance));
> if (c == 12) {//show 12 payments since there are 12
> a year
> //Thread.sleep(5000);//pause for 5 seconds
> c = 0;
> }
> }
> }
> }

e-mail: changed: ben to jpro91021@mac.com
-Ben
Andrew Thompson

2004-04-30, 1:22 pm

....
> e-mail: changed: ben to jpro91021@mac.....
> -Ben


That was very nice of you to offer to write
the OP's code for them. Could I ask you also
be nice to the rest of the members of the group
by trimming anything to which you are not directly
responding?

[ You just reposted around 260 lines,
simply to add 5. ]

Hoping you can see how trimming benefits all..

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com