3 Replies - 13004 Views - Last Post: 22 July 2012 - 05:18 AM Rate Topic: -----

#1 Sarajc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 08-May 12

java programming (Converting Fahrenheit to Celsius)

Posted 21 July 2012 - 07:43 PM

I wrote this program:
[code]import javax.swing.*;
public class Fahrenheit{
public static void main(String[]args){
double fahrenheit=Double.parseDouble(JOptionPane.showInputDialog("input fahrenheit"));
double celsius=((5.0/9)*( fahrenheit-32));
JOptionPane.showMessageDialog(null,"celsius="+celsius);
}
}
[/code]
to read a Fahrenheit degree in double from an input dialog box, then converts it to Celsius and displays the result in a message dialog box. The formula for the conversion is as follows:
celsius = (5/9) * (fahrenheit - 32)
i want to know if it is correct or not in everything like block styles

Is This A Good Question/Topic? 0
  • +

Replies To: java programming (Converting Fahrenheit to Celsius)

#2 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5364
  • View blog
  • Posts: 27,325
  • Joined: 10-May 07

Re: java programming (Converting Fahrenheit to Celsius)

Posted 21 July 2012 - 07:44 PM

** Moved to Java **

Site questions is for questions about the site. Programming questions go under the correct sub-forum for that language.
Was This Post Helpful? 0
  • +
  • -

#3 SilverEleak  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 33
  • Joined: 18-July 12

Re: java programming (Converting Fahrenheit to Celsius)

Posted 21 July 2012 - 08:49 PM

Yup this looks good.
It would be better though if you make it calculate from Celsius to Fahrenheit too.
Was This Post Helpful? 0
  • +
  • -

#4 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • Posts: 3,002
  • Joined: 30-January 11

Re: java programming (Converting Fahrenheit to Celsius)

Posted 22 July 2012 - 05:18 AM

I'm not sure what you want to know. It's three lines of code - there aren't many ways you can write it.

But in terms of block styles you don't have any indentation which makes it look messy.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1