JAVA: Celsius to Fahrenheit Conversion
Tarih: 28 Kasım 2013 Yorum: 0

(Celsius to Fahrenheit conversion) Write a program that displays a table of temperatures from 0C to 20C and their Fahrenheit equivalents. The formula for converting from the Celsius scale to the Fahrenheit scale is
F= (9/5) C + 32
where F is the temperature in Fahrenheit and C is the temperature in Celsius.

 

CelsiustoFahrenheit.java

/**
 * Celsius to Fahrenheit conversion.
 */

	import javax.swing.JOptionPane;	// import JOptionPane.
public class CelsiustoFahrenheit {

    public static void main(String[] args) {

    	float fahrenheit,celcius;
		String result = "";

  			for(celcius=0;celcius<=20;celcius++){

    			fahrenheit = (celcius*9/5)+32;	// Convert formula.

 				result += celcius +" Celcius = " + fahrenheit +" Fahrenheit \n";

    		} // End of for loop.

    	// Print table.
    	JOptionPane.showMessageDialog(null,result,"The Table Of Celcius to Fahrenheit Conversion",JOptionPane.INFORMATION_MESSAGE);	

    } // End of main method.
} // End of class.



Yorum Yok:


Yorum Yap:

Yorum yapabilmek için giriş yapmalısınız.




tema yapımcısı wordpress alexa bilgileri Webmaster Creative Commons v3 ile Lisanslanmıştır!


Akif ARSLAN © 2012 - 2024
Sitede bulunan istediğiniz cümleyi veya içeriği, istediğiniz gibi, istediğiniz yerde, istediğiniz zaman ve istediğiniz kişilerle paylaşabilirsiniz.