I am confused as to why I have a non static method error. It says "non-static method getGrade(double) cannot be referenced from a static context getGrade(myGPA);" I have been reading on what non static method. I get it I can't call something that doesn't exist. Since you haven't created an object, the non-static method doesn't exist yet. A static method (by definition) always exists. So this is my code below, and the error says "non-static method getGrade(double) cannot be referenced from a static context getGrade(myGPA);" I created an object of that, but gave me a "cannot find symbol error." I know it is something minor, can someone please guide me as to what I can do? THANK YOU in advance!
The program is supposed to take the user's input (GPA, in decimal format, and covert that into percentile, and response to the user.
import java.util.Scanner;
public class GradeCalc {
public double myGPA;
public double numGrade;
public static void main (String[] args) {
Scanner myScanner = new Scanner (System.in);
System.out.println("Enter your GPA.");
double myGPA= myScanner.nextDouble();
getGrade(myGPA);
System.out.println(myGPA);
}
public double getGrade(double myGPA) {
if(myGPA==0.0 || myGPA==0.8 || myGPA==0.9 || myGPA==1.0 || myGPA==1.1 ||
||myGPA==1.8 || myGPA==1.9 || myGPA==2.0 || myGPA==2.1 || myGPA==2.2 || myGPA==2.3 || myGPA==2.4 || myGPA==2.5 || myGPA==2.6 || myGPA==2.7 || myGPA==2.8 || myGPA==2.9 || myGPA==3.0 || myGPA==3.1 || myGPA==3.2 || myGPA==3.3 || myGPA==3.4 || myGPA==3.5 || myGPA==3.6 || myGPA==3.7 || myGPA==3.8 || myGPA==3.9 || myGPA==4.0 ) {
double numGrade = (myGPA*10+55);
}
if (myGPA == numGrade)
System.out.println(numGrade);
else {
System.out.println("Try again.");
}
return numGrade;
}
}