I am new on this and I will be working in a gpa and average program.
This is my code so far:
Everytime that I try to add the gpa part it gives me errors or just duplicates whatever I've in average and displays it in gpa
/** * This program shows a database of students in a school. * It gathers information as name, classes, grades, and calculates average and gpa average. * */ import javax.swing.JOptionPane; public class StudentReport { public static void main(String[]args) { String name; String schoolName; String schoolGrade; double numOfSubjects; double grades=0; double average; String trash; name=JOptionPane.showInputDialog("Name:"); schoolGrade=JOptionPane.showInputDialog("Grade:"); schoolName=JOptionPane.showInputDialog("School:"); trash=JOptionPane.showInputDialog("Number of classes:"); numOfSubjects=Double.parseDouble(trash); //initialize average average=0.0; //get the grades added together in order to calculate the average for (int count1 = 1; count1 <=6; count1++) { trash=JOptionPane.showInputDialog("Test " + count1 + " : " ); count1=Integer.parseInt(trash); average=grades/numOfSubjects; //calculate average } JOptionPane.showMessageDialog(null, "School name: " + schoolName + "\n" + "Student: "+ name + " \n " + "School grade: " + schoolGrade + "\n" + "Average: " + average + "."); } }