aspose file tools*
The moose likes Java in General and the fly likes While Loop Problem(s) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "While Loop Problem(s)" Watch "While Loop Problem(s)" New topic
Author

While Loop Problem(s)

Andrew Garczynski
Greenhorn

Joined: Sep 28, 2012
Posts: 3
Hi, can some please point out the error im having with this code?


These are the errors i'm getting:
I:\2nd Year\OOP 2\WhileLoop.java:15: cannot find symbol
symbol : variable string
location: class WhileLoop
string.Format("Rate: %.2d \nAmount £: %2d \nEuros €: %.2d")
^
I:\2nd Year\OOP 2\WhileLoop.java:14: cannot find symbol
symbol : method showMessageDialog(<nulltype>,java.lang.String,double,double)
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog(null, "The conversion total is: " +
^


Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1824
    
    7

Those compiler warnings seem out of sync with the code you posted.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

i would expect the variables to go inside the string format method, just checked and yep, on the inside as a variable length argument list.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39885
    
  28
Having the variables added to String.format(...) with + operators should’t be a compiler error. The additional ) is, however. You can suffer an Exception when the % tags don’t match their arguments, but that is a problem for later on.
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

Campbell Ritchie wrote:Having the variables added to String.format(...) with + operators should’t be a compiler error. The additional ) is, however. You can suffer an Exception when the % tags don’t match their arguments, but that is a problem for later on.


see you learn something every day.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Andrew Garczynski wrote:
I:\2nd Year\OOP 2\WhileLoop.java:15: cannot find symbol
symbol : variable string
location: class WhileLoop
string.Format("Rate: %.2d \nAmount £: %2d \nEuros €: %.2d")
^


Read the message very closely. Remember, Java is case-sensitive.

I:\2nd Year\OOP 2\WhileLoop.java:14: cannot find symbol
symbol : method showMessageDialog(<nulltype>,java.lang.String,double,double)
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog(null, "The conversion total is: " +
^


The error message is telling you exactly what's wrong. (They usually do.) You're calling JOptionPane.showMessageDialog(null, String, double, double), but if you look at the docs for JOptionPane, you'll see there is no such method.
Andrew Garczynski
Greenhorn

Joined: Sep 28, 2012
Posts: 3
Got it to work, thanks guys
Andrew
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: While Loop Problem(s)