aspose file tools*
The moose likes Beginning Java and the fly likes code problem. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "code problem." Watch "code problem." New topic
Author

code problem.

fan tung
Greenhorn

Joined: Mar 22, 2003
Posts: 5
hi, i was trying to do temp. conver from f to c.
here is my part of my code. please help me.
/* Insert the method's description here.
* @param e java.awt.event.ActionEvent
*/
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == calcul)
calculate(fahTF.getText());

if(e.getSource() == reset)
{
fahTF.setText("");
celTF.setText("");
}
}
/**
* Insert the method's description here.
*/
public void calculate(double fah, double cel)
{

???
cel = (5/9 * (fah - 32));

}
and i got this compile error:
FrameTest2.java [78:1] calculate(double,double) in FrameTest2 cannot be applied to (java.lang.String)calculate(fahTF.getText());

thanks in advance.
fan
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
The method calculate has two formal parameters (double, double), you are calling calculate with one argument which looks like it could be a String.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
fan tung
Greenhorn

Joined: Mar 22, 2003
Posts: 5
can you show me how to fix that?
thank you so much!
fan
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 986

Actually that is only the first of you problems. From the code you posted it appears that you are trying to pass back the answer, "cal", as a parameter. That will not work in java. You need to pass it back as the return value.


Please ignore post, I have no idea what I am talking about.
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 986

fan tung
Greenhorn

Joined: Mar 22, 2003
Posts: 5
thanks William.

"I think Willims is right."(at least this time)
Jem Edwards
Greenhorn

Joined: Mar 28, 2003
Posts: 22
Hi fan tung:
It looks like you're working on the same problem that I'm working on!
Are you taking Introduction to Programming also?
I'm taking it via a web class and it's just like working alone - there's no class participation on the boards so besides reading this horribly boring book I also surf the web for easy to understand study guides.
In fact I found a site that explained increment & decrement operators better than the book cuz I just wasn't gettin' it.
Good Luck!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: code problem.