I m new.I am not getting any result for
Number of A
Number of B
Numbers of C
Number of D
number of F
for A,B,C,D,F i always get 0.
import java.util.Scanner;
public class ExamScores1
{
public static void main (String[]args)
{
String a;
int count= 0;
int grade=0; // you declare grade = 0 here
int A=0;
int B=0;
int C=0;
int D=0;
int F=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++;
}
}
// grade is still == 0 here
if (grade > 90 && grade <= 100) {
grade= 'A';
A=A+1;
count++;
} else if (grade > 80 && grade <= 89) {
grade= 'B';
B=B+1;
count++;
} else if (grade > 70 && grade <= 79) {
grade= 'C';
C=C+1;
count++;
} else if (grade > 60 && grade <= 69) {
grade= 'D';
D=D+1;
count++;
} else if (grade> 0 && grade <= 59) {
grade= 'F';
F=F+1;
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);
}
}