I could sure use some help. Here is what I have and it shows a problem which is :
int tempCelcius = (int)((Double.parseDouble(tempTextField.getText()))
(5 / 9) × (Fahrenheit – 32));
and here is all that I have:
/**
*
* @author TJ
*/
public class FahrenheitConverterGUI extends javax.swing.JFrame {
/** Creates new form FahrenheitConverterGUI */
public FahrenheitConverterGUI() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
tempTextField = new javax.swing.JTextField();
fahrenheitLabel = new javax.swing.JLabel();
convertButton = new javax.swing.JButton();
celciusLabel = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("FehrenheitConverter");
tempTextField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tempTextFieldActionPerformed(evt);
}
});
fahrenheitLabel.setText("Fahrenheit");
convertButton.setText("Convert");
convertButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
convertButtonActionPerformed(evt);
}
});
celciusLabel.setText("Celcius");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(tempTextField, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(convertButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(celciusLabel))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(fahrenheitLabel)))
.addContainerGap(40, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tempTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(fahrenheitLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(convertButton)
.addComponent(celciusLabel))
.addContainerGap(31, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void convertButtonActionPerformed(java.awt.event.ActionEvent evt) {
//Parse degrees Fahrenheit as a double and convert to Celcius.
int tempCelcius = (int)((Double.parseDouble(tempTextField.getText()))
(5 / 9) * (Fahrenheit – 32));
fahrenheitLabel.setText(tempCelcius + "Celcius");
}
private void tempTextFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FahrenheitConverterGUI().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel celciusLabel;
private javax.swing.JButton convertButton;
private javax.swing.JLabel fahrenheitLabel;
private javax.swing.JTextField tempTextField;
// End of variables declaration
}