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.

the first two errors are trying to say that they found string but you are trying to assign those strings into chars.
Solution: Make L1 and L2 Strings.
For the next two:
I hope you can understand that you haven't declared the variables 'gpa' and 'total'.
For the remaining errors, you have to post the GPAmathletter class.

Hope it helps.

Thanks a lot. Only question I have now is how do you enter information in your object with variables.

instead of

Code test = new Code ( 1, 2, 3);

I have variables established

Code test = new Code (var1, var2, var3);

This is how I have my code now

import java.util.Scanner;


class gpamain	{
	public static void main(String[] args)	{

Scanner usrin = new Scanner(System.in);
double gpa = 0
;

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");
				String L1 = usrin.next();
				System.out.println("Enter 2nd letter");
				String L2 = usrin.next();
					GPAmathletter one = new GPAmathletter (L1);
					double gpa001;
					gpa001 = gpa;
					GPAmathletter two = new GPAmathletter (L2);
					double gpa002;
					gpa002 = gpa;
					double total;
					total = gpa001 * gpa002 / 2;
			}
		}



	}
}

and

class GPAmathletter	{

	String L1;
	double gpa;

	GPAmathletter(String L1)	{
		String grade;
		grade = L1;



	}
	void processinputbyletter()	{
		if (grade.equals("A"))	{
				gpa = 4.00;
		}	else if (grade.equals("a")){
				gpa = 4.00;
		}	else if	(grade.equals("B")){
				gpa = 3.00;
		}	else if	(grade.equals("b")){
				gpa = 3.00;
		}	else if	(grade.equals("C")){
				gpa = 2.00;
		}	else if	(grade.equals("c")){
				gpa = 2.00;
		}	else if (grade.equals("D")){
				gpa = 1.00;
		}	else if (grade.equals("d")){
				gpa = 1.00;
		}	else if (grade.equals("F")){
				gpa = 0.00;
		}	else if	(grade.equals("f")){
				gpa = 0.00;
		}
	}




}

Code test = new Code (var1, var2, var3);
yes, that looks Ok if the Code class constructor takes 3 args and types of the args match the constructor.

well this is the error i receive when running.

--------------------Configuration: <Default>--------------------
C:\jclass\GPAmathletter.java:14: cannot find symbol
symbol  : variable grade
location: class GPAmathletter
		if (grade.equals("A"))	{
		    ^
C:\jclass\GPAmathletter.java:16: cannot find symbol
symbol  : variable grade
location: class GPAmathletter
		}	else if (grade.equals("a")){
		 	         ^
C:\jclass\GPAmathletter.java:18: cannot find symbol
symbol  : variable grade
location: class GPAmathletter
		}	else if	(grade.equals("B")){
		 	       	 ^
C:\jclass\GPAmathletter.java:20: cannot find symbol
symbol  : variable grade
location: class GPAmathletter
		}	else if	(grade.equals("b")){
		 	       	 ^
C:\jclass\GPAmathletter.java:22: cannot find symbol
symbol  : variable grade
location: class GPAmathletter
		}	else if	(grade.equals("C")){
		 	       	 ^
C:\jclass\GPAmathletter.java:24: cannot find symbol
symbol  : variable grade
location: class GPAmathletter
		}	else if	(grade.equals("c")){
		 	       	 ^
C:\jclass\GPAmathletter.java:26: cannot find symbol
symbol  : variable grade
location: class GPAmathletter
		}	else if (grade.equals("D")){
		 	         ^
C:\jclass\GPAmathletter.java:28: cannot find symbol
symbol  : variable grade
location: class GPAmathletter
		}	else if (grade.equals("d")){
		 	         ^
C:\jclass\GPAmathletter.java:30: cannot find symbol
symbol  : variable grade
location: class GPAmathletter
		}	else if (grade.equals("F")){
		 	         ^
C:\jclass\GPAmathletter.java:32: cannot find symbol
symbol  : variable grade
location: class GPAmathletter

		}	else if	(grade.equals("f")){
		 	       	 ^
10 errors

Process completed.

I think you were trying to compile the program from the errors you've posted. Runing a program usually means to execute the program not the compiler.

Where is the variable grade defined? The compiler can't find it in the same scope as where the errors are shown.
A variable defined local to a method is not known outside that method. Move the definition for grade outside of the method/constructor it is now in.

grade is L1, and L1 is the input the user gives.... A, B, C, D, a, b, c, d..... Still trying to make since of this..

Can you please give me an example??

well, the problem is with the scope of the variable 'grade'. You have declared 'grade' inside the GPAmathletter constructor and hence outside it it is no longer available.
Solution: declare 'grade' as an instance variable of the class. Just below String L1 and double gpa.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.