Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Need help please

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need help please

    Hi I am new to Java and have no clue what I am doing and I think my book is confusing me more than it is helping me. Here is what I need to do. 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. I know that I am supposed to create a loop but I have no clue how to do this correctly or even if the math portion of it is correct. I need some guidance please and also please try to tell me in a way that I can understand. And try not to laugh to much at my code lol. Here is what I have attempted so far:

    public class MortgageCalculator {
    private static double interest;


    public static void main(String[] args) {
    double annualInterest = 5.75; //This is the annual interest rate
    double loanAmount = 200000; //This is the loan amount
    double loanLengthInYears = 30; //This is the length of the loan in years


    //Formuals bieng used are:
    double monthlyInterest = annualInterest /100/12;
    double loanLengthInMonths = loanLengthInYears * 12;

    double monthlyPayment = (loanAmount * monthlyInterest) / (1 - Math.pow((1 + monthlyInterest), -loanLengthInMonths));
    DecimalFormat decimalPlaces=new DecimalFormat("0.00");//Rounds up the dollar amount



    System.out.println("MortgageCalculator");
    System.out.println("Annual Interest: 5.75%");
    System.out.println("Loan Amount: $200,000");
    System.out.println("Loan Length: 30 years");
    System.out.println("Monthly Payment: " + decimalPlaces.format(monthlyPayment));


    double currentLoanAmount;
    currentLoanAmount = loanAmount;
    while (currentLoanAmount >= 0.10)
    double interestPayment;
    interestPayment = (currentLoanAmount * monthlyInterest);
    double currentLoanAmount = currentLoanAmount - (monthlyPayment - interestPayment)




    System.out.println("loanAmount");
    System.out.println("Interest Payment");

    }
    }

  2. #2
    Member
    Join Date
    Dec 2011
    Location
    United States
    Posts
    94
    My Mood
    Amused
    Thanks
    5
    Thanked 8 Times in 8 Posts

    Default Re: Need help please

    You should check out some tutorials online to learn the basics. You cannot enclose variables in double quotes and expect to print out their values unless they are statements (Strings). After storing values in variables, all you need is to print that variable name and its content will be printed out.

  3. #3
    Junior Member
    Join Date
    Dec 2011
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help please

    Ive been looking online for the last week trying to figure it out... its just really confusing. Once I got the first formula I was able to come up with the first section but once I was required to input the loan balance and interest payments I got stuck. Ill keep looking though.