Hello everyone. I am very embarrassed to post my code cause some might think it is horrible since my experience level is low. But I am having a problem. First I want to add that i have tried placing
import java.lang.String
in the code but no go. Thanks in advance for all your help.
import java.util.Scanner;
class gpamain {
public static void main(String[] args) {
Scanner usrin = new Scanner(System.in);
System.out.println("How many classes have you taken? ");
int number_classes = usrin.nextInt();
if (number_classes == 2){
System.out.println("Type 1 for letter or 2 for grade number");
int grade_type = usrin.nextInt();
if (grade_type == 1){
System.out.println("Enter 1st letter");
char L1 = usrin.next();
System.out.println("Enter 2nd letter");
char L2 = usrin.next();
GPAmathletter one = new GPAmathletter (L1);
double gpa001;
gpa001 = gpa;
GPAmathletter two = new GPAmathletter (L2);
double gpa002;
gpa002 = gpa;
total = gpa001 * gpa002 / 2;
}
}
}
}
The error I receive when compiling....
--------------------Configuration: <Default>--------------------
C:\jclass\gpamain.java:19: incompatible types
found : java.lang.String
required: char
char L1 = usrin.next();
^
C:\jclass\gpamain.java:21: incompatible types
found : java.lang.String
required: char
char L2 = usrin.next();
^
C:\jclass\gpamain.java:24: cannot find symbol
symbol : variable gpa
location: class gpamain
gpa001 = gpa;
^
C:\jclass\gpamain.java:27: cannot find symbol
symbol : variable gpa
location: class gpamain
gpa002 = gpa;
^
C:\jclass\gpamain.java:28: cannot find symbol
symbol : variable total
location: class gpamain
total = gpa001 * gpa002 / 2;
^
C:\jclass\GPAmathletter.java:13: char cannot be dereferenced
if (grade.equals("A")) {
^
C:\jclass\GPAmathletter.java:15: char cannot be dereferenced
} else if (grade.equals("a")){
^
C:\jclass\GPAmathletter.java:17: char cannot be dereferenced
} else if (grade.equals("B")){
^
C:\jclass\GPAmathletter.java:19: char cannot be dereferenced
} else if (grade.equals("b")){
^
C:\jclass\GPAmathletter.java:21: char cannot be dereferenced
} else if (grade.equals("C")){
^
C:\jclass\GPAmathletter.java:23: char cannot be dereferenced
} else if (grade.equals("c")){
^
C:\jclass\GPAmathletter.java:25: char cannot be dereferenced
} else if (grade.equals("D")){
^
C:\jclass\GPAmathletter.java:27: char cannot be dereferenced
} else if (grade.equals("d")){
^
C:\jclass\GPAmathletter.java:29: char cannot be dereferenced
} else if (grade.equals("F")){
^
C:\jclass\GPAmathletter.java:31: char cannot be dereferenced
} else if (grade.equals("f")){
^
15 errors
Process completed.