Meaningless Drivel is fun!
The moose likes Beginning Java and the fly likes Temperature Converter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Temperature Converter" Watch "Temperature Converter" New topic

Temperature Converter

David Coello

Joined: Jun 05, 2012
Posts: 22
Hello forum members,

I am a new java developer. I have been working on a Converter from Farenheit to Celsius with the push of a button. I programmed it under those specs, but I would like to program that same button to convert back to celsius. I appreciate your comments, basically if a button can perform 2 actions, convert from Fahrenheit to Celsius and Celsius to Farenheit.

Thank you.


Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

Yes, the same button can do two things. You'd need an instance variable to remember which state the button is in so you know which label to display and which action to perform.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
check which textfield is empty, via .equals(""), ensuring both are not empty,
then convert the non-empty for display in the empty
I agree. Here's the link:
subject: Temperature Converter
jQuery in Action, 3rd edition