import javax.swing.JOptionPane;
public class StudentReport
{
String name; //name of the student
String schoolName; //name of the school
String schoolGrade; //grade in school
int numOfGrades; //number of grades or number of classes
double grades; //grades received
double average; //average of the grades
double total=0; //initialize total
String trash; //to convert string to double
public static void main(String[]args)
{
public getInformation()
{
//ask user for Name, grade, school
name=JOptionPane.showInputDialog("Name:");
schoolGrade=JOptionPane.showInputDialog("Grade:");
schoolName=JOptionPane.showInputDialog("School:");
//ask user to enter number of grades
trash=JOptionPane.showInputDialog("Number of grades:");
numOfGrades=Integer.parseInt(trash);
}
public getAvg()
{
//get the grades added together in order to calculate the average
for (int i = 1; i <=numOfGrades; i++)
{
trash=JOptionPane.showInputDialog("Test " + i + " : " );
grades =Integer.parseInt(trash);
//calculate total
total+=grades;
//calculate average
average=total/numOfGrades;
}
}
//display window showing information
JOptionPane.showMessageDialog(null, "School name: " + schoolName + "\n"
+ "Student: "+ name + " \n "
+ "School grade: " + schoolGrade + "\n"
+ "Average: " + average + ".");
}
}
}
How can make this class to send information to another class
Like I am writing a class that calculate gpa and needs the average of this class and the information
of the user.
I don't know what to add in order to convert the methods and be able to call them from another class
I am new in java.