Hello, I'm currently taking a Java course and I'm not sure what's wrong with my code. I had to cut a lot of it out but this is the gist of it (it's a GUI):
public static void main(String args[]) {
double coursemark1;
double coursemark2;
double coursemark3;
double coursemark4;
char percent;
double result;
percent = '%';
coursemark1 = Double.parseDouble(txtmarkinput1.getText());
coursemark2 = Double.parseDouble(txtmarkinput2.getText());
coursemark3 = Double.parseDouble(txtmarkinput3.getText());
coursemark4 = Double.parseDouble(txtmarkinput4.getText());
result = percent + (coursemark1 + coursemark2 + coursemark3 + coursemark4) / 4;
result = result * 100;
result = Math.round (result);
result = result/100;
lblAnswer.setText(String.vaueOf(result));
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(averageproject.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(averageproject.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(averageproject.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(averageproject.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new averageproject().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton buxcalulate;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel lblAnswer;
private javax.swing.JLabel lblcoursemark1;
private javax.swing.JLabel lblcoursemark2;
private javax.swing.JLabel lblcoursemark3;
private javax.swing.JLabel lblcoursemark4;
private javax.swing.JTextField txtmarkinput1;
private javax.swing.JTextField txtmarkinput2;
private javax.swing.JTextField txtmarkinput3;
private javax.swing.JTextField txtmarkinput4;
// End of variables declaration
}