Code Help with GUI Mortgage Calculator


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Code Help with GUI Mortgage Calculator

  1. #1
    Join Date
    Oct 2006
    Posts
    3

    Code Help with GUI Mortgage Calculator

    Hello I'm trying to create a Mortgage Calculator that accepts user's input for loan amount, loan interest rate, and loan term and then displays the monthly payment for the Mortgage in GUI form. When I compile my program I get a error message stating cannot find symbol method showMessageDialog(<nulltype>,java.lang.String,int)

    HERE IS MY CODE BELOW PLEASE HELP

    import java.text.DecimalFormat;
    import javax.swing.JOptionPane;

    public class MortgageCalculatorServiceRequest4///Name of my File and Class
    {
    public static void main(String[] args)
    {
    double loanAmount;//Declaring my Variables
    double loanInterest;//Declaring my Variables
    double monthlyPayment;//Declaring my Variables
    double interestRate;
    int loanTerm;
    String totalLoan, interestLoan, termLoan;
    DecimalFormat decimalPlaces=new DecimalFormat("0.00"); //Format decimal point for proper display

    totalLoan=JOptionPane.showInputDialog(null, "Enter the Term of the Loan: ");
    loanAmount = Double.parseDouble(totalLoan);

    interestLoan=JOptionPane.showInputDialog(null, "Enter the Interest Rate of the Loan in decimal Form: ");
    loanInterest = Double.parseDouble(interestLoan)/12;

    termLoan=JOptionPane.showInputDialog(null, "Enter the Term of the Loan: ");
    loanTerm = Integer.parseInt(termLoan)*12;

    // calculations
    monthlyPayment = (loanAmount * loanInterest) / (1 - Math.pow(1 + loanInterest, -loanTerm));//Formula for Monthly Payments

    JOptionPane.showMessageDialog(null,"Your Monthly Payments Are" + decimalPlaces.format(monthlyPayment),JOptionPane.PLAIN_MESSAGE );
    System.exit(0);
    }}
    Last edited by drewdat7001; 10-23-2006 at 11:05 PM. Reason: forgot something

  2. #2
    Join Date
    Dec 2005
    Posts
    97
    its because
    Code:
    JOptionPane.showMessageDialog(null,"Your Monthly Payments Are" + decimalPlaces.format(monthlyPayment),JOptionPane.PLAIN_MESSAGE );
    does not pass the parameters that are expected by the showMessageDialog method. take a look at the documentation and then modify your code from there

    http://java.sun.com/j2se/1.4.2/docs/...ptionPane.html

  3. #3
    Join Date
    Oct 2006
    Posts
    3
    Thank you,

    Is it because (monthlyPayment) is a double and the JOptionPane.showMessageDialog is set up for a integer?

  4. #4
    Join Date
    Dec 2005
    Posts
    97
    no, the double gets "converted" into a String because you are concatenating it to a String. just change
    Code:
    JOptionPane.showMessageDialog(null,"Your Monthly Payments Are" + decimalPlaces.format(monthlyPayment),JOptionPane.PLAIN_MESSAGE );
    to
    Code:
    JOptionPane.showMessageDialog(null,"Your Monthly Payments Are" + decimalPlaces.format(monthlyPayment));
    that should work.

  5. #5
    Join Date
    Dec 2006
    Posts
    2

    new bie

    hi guys i am new to this place ...i found lot of active participation is going on here regarding the code ..

    sounds interesting .....


    regards ,
    gudipudi

Similar Threads

  1. GPA Calculator code in pl/sql
    By Gaujon in forum Database
    Replies: 1
    Last Post: 11-08-2011, 05:29 PM
  2. Mortgage Calculator Help
    By vwrado in forum Java
    Replies: 7
    Last Post: 09-06-2005, 06:06 PM
  3. Make VB code work in MS Access 2000?
    By Pihlis in forum VB Classic
    Replies: 2
    Last Post: 07-17-2002, 01:34 AM
  4. Code security
    By Rob Teixeira in forum .NET
    Replies: 5
    Last Post: 11-27-2001, 07:12 PM
  5. Brain Washing
    By Danny Bowman in forum .NET
    Replies: 152
    Last Post: 09-13-2001, 08:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center