This tutorial will teach you on how you can create a “ Grade Average Calculator using Java”J with Netbeans IDE. This program will calculate the Grade Average by Sum the Prelim, Midterm, and Final Grade and Divide it by 3.
Related Article: Basic calculator Using Java with GUI
Also, uses an “If Function Statement” to identify the grade average if it is Passed or Failed. The elements of the JFrame form compose of jTextField, jLabel, and jButton. Please follow all the steps to complete this tutorial
Grade Average Calculator Using Java Steps
- Create a new JFrame Form and Design it the same with the image below.
2. Double click your jButton and Insert the following codes below.
[java]try{
double average;
double prelim = Double.parseDouble(jTextField1.getText());
double midterm = Double.parseDouble(jTextField2.getText());
double finalg = Double.parseDouble(jTextField3.getText());
average = (prelim + midterm + finalg) / 3;
jTextField4.setText(Double.toString(average));
if (Double.parseDouble(jTextField4.getText()) <= 74.4){
jTextField5.setText(“Failed!”);
}else{
jTextField5.setText(“Passed!”);
}
}catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}[/java]
3. Run your program and the output should look like the image below.
For more information, feel free to leave your comment below, use the contact page of this website or use my contact information.
Email: [email protected] | Cell. No.: 09468362375