-
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
-
looks to me that your Path is not set to include the location of the JDK
-
very thing worked out by changing p into P on the JOptionPane. thanks for your help.
Similar Threads
-
By dmb-job in forum VB Classic
Replies: 6
Last Post: 01-01-2007, 02:18 AM
-
By Coolgoose in forum VB Classic
Replies: 1
Last Post: 11-29-2006, 06:48 PM
-
By Karl Robinson in forum VB Classic
Replies: 7
Last Post: 07-23-2001, 10:58 AM
-
By bigbastard4 in forum Database
Replies: 2
Last Post: 05-16-2001, 06:24 PM
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks