Click here to Skip to main content
15,890,579 members
Home / Discussions / Java
   

Java

 
QuestionTrouble with my loop ~I think Pin
Bactos8-Mar-09 11:35
Bactos8-Mar-09 11:35 
AnswerRe: Trouble with my loop ~I think Pin
fly9049-Mar-09 0:34
fly9049-Mar-09 0:34 
GeneralRe: Trouble with my loop ~I think Pin
Bactos9-Mar-09 6:52
Bactos9-Mar-09 6:52 
GeneralRe: Trouble with my loop ~I think Pin
fly9049-Mar-09 9:30
fly9049-Mar-09 9:30 
GeneralRe: Trouble with my loop ~I think Pin
Bactos9-Mar-09 11:19
Bactos9-Mar-09 11:19 
GeneralRe: Trouble with my loop ~I think Pin
fly9049-Mar-09 12:06
fly9049-Mar-09 12:06 
GeneralRe: Trouble with my loop ~I think Pin
Bactos9-Mar-09 14:41
Bactos9-Mar-09 14:41 
GeneralRe: Trouble with my loop ~I think Pin
Bactos9-Mar-09 15:33
Bactos9-Mar-09 15:33 
Ok so here is what I have now....




////Write the program in Java (without a graphical user interface)
//// using a loan amount of $200,000 with an interest rate of 5.75% and
//// a 30 year term. Display the mortgage payment amount and then list the
//// loan balance and interest paid for each payment over the term of the loan.
//// If the list would scroll off the screen, use loops to display a partial list,
//// hesitate, and then display more of the list.
//// */
////

import java.text.DecimalFormat;

public class CR1 {

/**
* @param args the command line arguments
*/

public static void main(String[] args) {

DecimalFormat dollarAmount = new DecimalFormat("0.00");

double loan_amount = 200000.00; // amount of the loan
int terminyears = 30; // term of the loan in years
int number_of_payments = terminyears*12; // sets
double intrest_rate = 5.75; // intrest rate of the loan

double monthly_intrest_rate = intrest_rate/100/12; // calculates monthly inrest rate

double loanbalance = loan_amount - number_of_payments;
double monthly_payment = monthly_intrest_rate/(1 - Math.pow(1+monthly_intrest_rate,-number_of_payments)) * loan_amount;


double P = loan_amount;
double M = monthly_payment;
double J = monthly_intrest_rate;
int N = number_of_payments;



//double ipaid = monthly_payment * .0575;


int pCounter = 0; // sets counter to zero

for (int i =0; i < 359; i++)
{

double H = P * J;
double C = M - H;
double Q = P- C;
P=Q;

System.out.println("Payment Number:" +i);
System.out.println("Monthly Payment:$"+ dollarAmount.format (M));
System.out.println("Loan Balance: $" + dollarAmount.format (Q));
System.out.println("Intrest Paid:$ " + dollarAmount.format (H));
System.out.println();

pCounter += 0;

}//end for

if (pCounter ==9 )
{

try
{
Thread.sleep(20000000);
pCounter = 0;
}// end try
catch(InterruptedException e)
{

//
}// end catch

}// end if


if (loanbalance < 0)
{
System.out.println("Than you for using Billy's Program. Have a good DAY!!!");
System.exit(0);
}// end else

} // end main

}// end program


Everything works!!.. Thanks for your help.

Bactos

AnswerRe: Trouble with my loop ~I think Pin
Reagan Conservative9-Mar-09 9:03
Reagan Conservative9-Mar-09 9:03 
GeneralRe: Trouble with my loop ~I think Pin
Bactos9-Mar-09 11:33
Bactos9-Mar-09 11:33 
GeneralRe: Trouble with my loop ~I think Pin
Bactos9-Mar-09 15:34
Bactos9-Mar-09 15:34 
Questionconversion of a color image into a black white image Pin
sudipkumar036-Mar-09 22:23
sudipkumar036-Mar-09 22:23 
JokeRe: conversion of a color image into a black white image Pin
fly9047-Mar-09 8:38
fly9047-Mar-09 8:38 
GeneralRe: conversion of a color image into a black white image Pin
sudipkumar0316-Mar-09 20:12
sudipkumar0316-Mar-09 20:12 
AnswerRe: conversion of a color image into a black white image Pin
fly9047-Mar-09 8:42
fly9047-Mar-09 8:42 
QuestionRead Incoming SMS Pin
Nitharshan6-Mar-09 19:34
Nitharshan6-Mar-09 19:34 
RantRe: Read Incoming SMS Pin
fly9047-Mar-09 9:04
fly9047-Mar-09 9:04 
Questionusing COM objects from Java that runs on SUN Java VM under MS platforms Pin
Varghese Paul M6-Mar-09 16:12
Varghese Paul M6-Mar-09 16:12 
QuestionHelp with adding url to form input after .value Pin
steelwidow5-Mar-09 7:12
steelwidow5-Mar-09 7:12 
AnswerRe: Help with adding url to form input after .value Pin
Curtis Schlak.5-Mar-09 10:57
Curtis Schlak.5-Mar-09 10:57 
QuestionCode to extract a pixel from video stream Pin
Jincy C J4-Mar-09 20:06
Jincy C J4-Mar-09 20:06 
AnswerRe: Code to extract a pixel from video stream Pin
Smithers-Jones11-Mar-09 23:00
Smithers-Jones11-Mar-09 23:00 
Questionreading Pixel value from a image [modified] Pin
sudipkumar034-Mar-09 19:48
sudipkumar034-Mar-09 19:48 
QuestionPing using UDP Pin
tiger08064-Mar-09 5:03
tiger08064-Mar-09 5:03 
AnswerRe: Ping using UDP Pin
fly9044-Mar-09 8:51
fly9044-Mar-09 8:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.