cannot find symbol


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: cannot find symbol

  1. #1
    Join Date
    Jun 2007
    Posts
    2

    cannot find symbol

    hi i am new for java. i copy this code from a book and got error message.
    pls help.

    // Compute Mortgage.java: compute mortgage payments
    import javax.swing.JOptionPane;
    public class ComputeMortgage {
    /**main method*/
    public static void main(String[] args) {
    double annualInterestRate;
    int numOfYears;
    double loanAmount;
    // Enter yearly interest rate
    String annualInterestRateString = JOptionpane.showInputDialog(
    null,"Enter yearly interest rate, for example 8.25: ", "Example 2.3 Input",
    JOptionpane.QUESTION_MESSAGE);
    //Convert string to double
    annualInterestRate= Double.parseDouble(annualInteresRateString);
    //obtain monthly interest rate
    double monthlyInterestRate= annualInterestRate/1200;
    //Enter number of years
    String numOfYearsString=JOptionpane.showInputDialog
    (null, "Enter number of ears as an integer,\nfor example 5:",
    "Example 2.3 Input", JOptionpane.QUESTION_MESSAGE);
    //Convert string to int
    numOfYears= Integer.parseInt(numOfYearsString);
    //Enter loan amount
    String loanString = JOptionpane.showInputDialog
    (null,"Enter number of years as an integer,\nfor example 5:",
    "Example 2.3 Input",JOptionpane.QUESTION_MESSAGE);
    //Convert string to double
    loanAmount= Double.parseDouble(loanString);
    //Calculate payment
    double monthlypayment=loanAmount*monthlyInterestRate/
    (1-1/Math.pow(1+monthlyInterestRate,numOfYear*12));
    double totalpayment=monthlypayment*numOfYears*12;
    //Format to keep two digits after the decimal point
    monthlypayment=(int)(monthlypayment*100)/100.0;
    totalpayment=(int)(totalpayment*100)/100.0;
    //Dispaly results
    String output="The monthly payment is "+ monthlypayment +
    "\nThe total payment is "+ totalpayment;
    JOptionpane.showMessageDialog(null,output,
    "Example 2.3 output", JOptionpane.INFORMATION_MESSAGE);
    System.exit(0);
    }
    }
    /*****************'
    C:\programming_in_java\JavaApplication1\ComputeMortgage.java:12: cannot find symbol
    symbol : variable JOptionpane
    location: class ComputeMortgage
    JOptionpane.QUESTION_MESSAGE);
    ^
    C:\programming_in_java\JavaApplication1\ComputeMortgage.java:10: cannot find symbol
    symbol : variable JOptionpane
    location: class ComputeMortgage
    String annualInterestRateString = JOptionpane.showInputDialog(
    ^
    C:\programming_in_java\JavaApplication1\ComputeMortgage.java:14: cannot find symbol
    symbol : variable annualInteresRateString
    location: class ComputeMortgage
    annualInterestRate= Double.parseDouble(annualInteresRateString);
    ^
    C:\programming_in_java\JavaApplication1\ComputeMortgage.java:20: cannot find symbol
    symbol : variable JOptionpane
    location: class ComputeMortgage
    "Example 2.3 Input", JOptionpane.QUESTION_MESSAGE);
    ^
    C:\programming_in_java\JavaApplication1\ComputeMortgage.java:18: cannot find symbol
    symbol : variable JOptionpane
    location: class ComputeMortgage
    String numOfYearsString=JOptionpane.showInputDialog
    ^
    C:\programming_in_java\JavaApplication1\ComputeMortgage.java:26: cannot find symbol
    symbol : variable JOptionpane
    location: class ComputeMortgage
    "Example 2.3 Input",JOptionpane.QUESTION_MESSAGE);
    ^
    C:\programming_in_java\JavaApplication1\ComputeMortgage.java:24: cannot find symbol
    symbol : variable JOptionpane
    location: class ComputeMortgage
    String loanString = JOptionpane.showInputDialog
    ^
    C:\programming_in_java\JavaApplication1\ComputeMortgage.java:31: cannot find symbol
    symbol : variable numOfYear
    location: class ComputeMortgage
    (1-1/Math.pow(1+monthlyInterestRate,numOfYear*12));
    ^
    C:\programming_in_java\JavaApplication1\ComputeMortgage.java:40: cannot find symbol
    symbol : variable JOptionpane
    location: class ComputeMortgage
    "Example 2.3 output", JOptionpane.INFORMATION_MESSAGE);
    ^
    C:\programming_in_java\JavaApplication1\ComputeMortgage.java:39: cannot find symbol
    symbol : variable JOptionpane
    location: class ComputeMortgage
    JOptionpane.showMessageDialog(null,output,
    ^
    10 errors

    Tool completed with exit code 1

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    looks to me that your Path is not set to include the location of the JDK

  3. #3
    Join Date
    Jun 2007
    Posts
    2
    very thing worked out by changing p into P on the JOptionPane. thanks for your help.

Similar Threads

  1. Close IE 'Find' with VB6 code
    By dmb-job in forum VB Classic
    Replies: 6
    Last Post: 01-01-2007, 02:18 AM
  2. Replies: 1
    Last Post: 11-29-2006, 06:48 PM
  3. Find Method with Multiple Criteria
    By Karl Robinson in forum VB Classic
    Replies: 7
    Last Post: 07-23-2001, 10:58 AM
  4. SQL Tutorial (Answer Q's & post your reply)
    By bigbastard4 in forum Database
    Replies: 2
    Last Post: 05-16-2001, 06:24 PM
  5. ado find
    By Mike in forum VB Classic
    Replies: 0
    Last Post: 08-23-2000, 08:29 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