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 4 of 4

Thread: Help needed writing a program using JOptionPane

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help needed writing a program using JOptionPane

    Write a Java program that lets the user enter the loan amount and loan period in number of years and
    displays the monthly and total payments for each annual interest rate starting from 3.5% to 8% with an
    increment of 0.25%. Below are the formulas that can be used to calculate monthlyPayment & totalPayment.

    factor = 1/ 1+(annualInterestRate/1200)

    monthlyPayment = loanAmount * (1 - factor) / (factor * (1 - Math.pow(factor, numOfYears * 12)))


    totalPayment = monthlyPayment * 12 * numOfYears;


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Help needed writing a program using JOptionPane

    And...what's the problem? What have you tried? Where are you stuck? Suggest you read the link in my signature for getting help

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help needed writing a program using JOptionPane

    Quote Originally Posted by copeg View Post
    And...what's the problem? What have you tried? Where are you stuck? Suggest you read the link in my signature for getting help
    This is what I have so far and I obviously know it's not correct at all. This is my very first time writing something like this JOptionPane.

    import javax.swing.JOptionPane;

    public class Payment {

    public static void main (String [] args) {

    String numOfYears;
    double annualInterestRate;
    double loanAmount;
    //String monthlyPayment;
    //String totalPayment;


    String loanAmountString = JOptionPane.showInputDialog (null,
    "Please enter the loan amount:",
    "Lab Assignment 1",
    JOptionPane.QUESTION_MESSAGE);
    double monthlyPayment = Double.parseDouble(loanAmountString);
    double totalPayment = Double.parseDouble(loanAmountString);

    numOfYears = JOptionPane.showInputDialog (null,
    "Please enter the number of years:",
    "Lab Assignment 1",
    JOptionPane.QUESTION_MESSAGE);


    //totalPayment = Double.parseDouble (monthlyPayment * 12 * numOfYears);


    }

    }

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Help needed writing a program using JOptionPane

    I'll reiterate, if you want quality help I recommend reading the getting help link in my signature. It describes the questions you should ask as well as how to use the code tags so your code is readable.

Similar Threads

  1. writing a program to interface with other programs
    By gib65 in forum File I/O & Other I/O Streams
    Replies: 6
    Last Post: November 4th, 2011, 04:16 PM
  2. [SOLVED] Writing a program with arrays and class methods... PLEASE HELP?
    By syang in forum What's Wrong With My Code?
    Replies: 17
    Last Post: August 8th, 2011, 07:02 AM
  3. Question about writing a phonebook sorting program
    By Stockholm Syndrome in forum Java Theory & Questions
    Replies: 2
    Last Post: March 25th, 2011, 09:25 AM
  4. Average program with array and loop and JOptionPane.
    By jeremykatz in forum AWT / Java Swing
    Replies: 6
    Last Post: October 25th, 2009, 02:33 PM
  5. I need help writing this program
    By kev2000 in forum Algorithms & Recursion
    Replies: 5
    Last Post: June 4th, 2009, 03:14 AM