title:Calculate Celsius to Fahrenheit Temperature in Java
date:2012-06-16 15:31:13
categories:
-Codes
tags:
-code-example
- java
- swing
---
In-order to convert from Celsius to Fahrenheit, we have to apply a simple logic onto Celsius "Multiply by 9, then divide by 5, then add 32".
Our code provides a simple GUI, where the user has to enter the temperature in Celsius and after clicking on convert displays the Fahrenheit temperature below button in the form of JLabel.
The Class has been designed by extending JPanel which can be called from other classes and added onto the JFrame for displaying.
#### Screenshot

#### C2F.java
```java
packagecom.rohansakhale.treedemo;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjavax.swing.BoxLayout;
importjavax.swing.JButton;
importjavax.swing.JFrame;
importjavax.swing.JLabel;
importjavax.swing.JPanel;
importjavax.swing.JTextField;
/**
*
* @author RohanSakhale
*/
publicclassC2FextendsJPanel{
JTextFieldtfInputTemp;
JLabellInputTemp,lAnswer;
JButtonbCalc;
JPanelInputTemp,collections;
publicC2F(){
tfInputTemp=newJTextField(15);
lInputTemp=newJLabel("Enter Temperature in Celsius: ");
title:Calculate Fahrenheit to Celsius Temperature in Java
date:2012-06-16 15:31:03
categories:
-Codes
tags:
-code-example
- java
- swing
---
In-order to convert from Fahrenheit to Celsius, we have to apply a simple logic onto Celsius "Deduct 32, then multiply by 5, then divide by 9".
Our code provides a simple GUI, where the user has to enter the temperature in Fahrenheit and after clicking on convert displays the Celsius temperature below button in the form of JLabel.
The Class has been designed by extending JPanel which can be called from other classes and added onto the JFrame for displaying.
#### Screenshot:

#### F2C.java
```java
packagecom.rohansakhale.treedemo;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjavax.swing.BoxLayout;
importjavax.swing.JButton;
importjavax.swing.JFrame;
importjavax.swing.JLabel;
importjavax.swing.JPanel;
importjavax.swing.JTextField;
/**
*
* @author RohanSakhale
*/
publicclassF2CextendsJPanel{
JTextFieldtfInputTemp;
JLabellInputTemp,lAnswer;
JButtonbCalc;
JPanelInputTemp,collections;
publicF2C(){
tfInputTemp=newJTextField(15);
lInputTemp=newJLabel(\"Enter Temperature in Fahrenheit: \");
In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example,
```
5! = 5 x 4 x 3 x 2 x 1 = 120
```
The following code creates a GUI for calculating factorial numbers upto 170.
The user has to enter the number and click on Calculate which displays the answer on JLabel below the button.
The Class has been designed by extending JPanel which can be called from other classes and added onto the JFrame for displaying.
#### Screenshot
