• October 22nd, 2013, 08:22 AM
jelliotgordon
Ok The problem is that there are 20 grades inside an array. The answer is supposed to be a displayed by grade level is 85 >= A , <84 = B, <=75 =C. I can't get the program to excecute. I am trying to use an else if statement and it keeps coming up with errors please help! This is the program I have written. I know it may be a little sloppy, I am a beginner so any syntax help is also appreciated.

public class problem2{
public static void main (String []args){
Scanner scan= new Scanner(System.in);
int a []= new int [20];
for (int k=0; k<20;k++)
a[k] = scan.nextInt ();
char b[]= new char[20];
int x=0, y=0,z=0;
for (int i=0; i<20;i++)
int a[]= {90,91,93,94,95,84,82,81,86,87,73, 74, 75,76,77, 76, 71, 86, 87,88};

{
if a[i].=85)
b[i]='A';
else if((a[i]<84) && (a[i]>=75))
else
b[i]='B';

else
b[i]='C'
}
for (int j= 0;j<20;j++)
if (b[j]=='A')
{x++}
else if (b[j]=='B')
y++;
else
z++;
}
System.out.println("Number of students getting A = "+ x");
System.out.println("Number of students getting A = "+ y");
System.out.println("Number of students getting A = "+ z");
}
}
}
• October 24th, 2013, 02:31 AM
uma2712
I have tried from your problem statement.

Try this..

Quote:

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

int a[] = { 90, 91, 93, 94, 95, 84, 82, 81, 86, 87, 73, 74, 75, 76, 77,
76, 71, 86, 87, 88 };

for (int i = 0; i < a.length; i++) {
if (a[i] >= 85) {