Hi i am looking for following output.I am not getting these.
System.out.println(total no of grades)
Number of A's
Number of B
Numbers of C
Number of D
number of F

import java.util.Scanner;
public class ExamScores
{
	public static void main (String[]args)
	{
		String a;
		int count= 0;
		String word;
		int grade=0;




	Scanner scan = new Scanner (System.in);
	System.out.println("Enter your exam grades");


	a=scan.nextLine();
	int len=a.length ();

	for (int i=0; i< len; i++)
	{
		if (a.charAt (i) ==' '){
		count--;
	}else {
		count++;

	System.out.println(count);
}
}




if (grade > 90 && grade <= 100) {
grade= 'A';
} else if (grade > 80 && grade <= 89) {
grade= 'B';

} else if (grade > 70 && grade <= 79) {
grade= 'C';

} else if (grade > 60 && grade <= 69) {
grade= 'D';

} else if (grade> 0 && grade <= 59) {
grade= 'F';
}
System.out.print( grade);
}
}

Down to line 30 you compute a value for count (although I have no idea what that value is supposed to be) then from line 35 you start testing the value of grade. Nowhere before line 35 do you set any value for grade.
After you fix that you still use the same variable grade both for the input numeric value and the output character. Two different variables would be better.

so these are my cods.

import java.util.Scanner;
public class ExamScores
{
	public static void main (String[]args)
	{
		String a;
		int count= 0;
		int grade=0;
		char A,B,C,D,F;




	Scanner scan = new Scanner (System.in);
	System.out.println("Enter your exam grades");


	a=scan.nextLine();
	int len=a.length ();

	for (int i=0; i< len; i++)
	{
		if (a.charAt (i) ==' '){
		count--;
	}else {
		count++;

}
}




if (grade > 90 && grade <= 100) {
grade= 'A';
count++;
} else if (grade > 80 && grade <= 89) {
grade= 'B';

} else if (grade > 70 && grade <= 79) {
grade= 'C';
count++;

} else if (grade > 60 && grade <= 69) {
grade= 'D';
count++;
} else if (grade> 0 && grade <= 59) {
grade= 'F';
count++;
}
System.out.println("total no of grades=" + count);
System.out.println("Number of A=" + A);
System.out.println("Number of B=" + B);
System.out.println("Number of C=" + C);
System.out.println("Number of D=" + D);
System.out.println("Number of F=" + F);
}
}
This article has been dead for over six months. Start a new discussion instead.