• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Temperature Converter

 
David Coello
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

David

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34870
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check which textfield is empty, via .equals(""), ensuring both are not empty,
then convert the non-empty for display in the empty
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic