help me complete this code pleaseSolutionHelloBased on what
help me complete this code please
Solution
Hello,Based on what I understood the requirement ,I developed this code.If any there is any thing I have to modify in this code Just give me clarification.I will do it according to your requirement.Thank You.
Arrays.java
public class Arrays {
public static void frequency(int [] a, int size)
{
int ninties=0,eighties=0,seventies=0,sixties=0;
//go thru each element in array and
//get a count of grades
//i.e count the 90-100\'s
//count 80\'s - 89\'s
//continue count up to the 60\'s
for(int i=0;i<size;i++)
{
if(a[i]>=90 && a[i]<=100)
{
ninties++;
}
else if(a[i]>=80 && a[i]<=89)
{
eighties++;
}
else if(a[i]>=70 && a[i]<=79)
{
seventies++;
}
else if(a[i]>=60 && a[i]<=69)
{
sixties++;
}
}
System.out.println(\"No of grades between 90 and 100 are:\"+ninties);
System.out.println(\"No of grades between 80 and 89 are:\"+eighties);
System.out.println(\"No of grades between 70 and 79 are:\"+seventies);
System.out.println(\"No of grades between 60 and 69 are:\"+sixties);
int gradeCt[] = new int[4];
for(int i=0;i<size;i++)
{
if(a[i]>=90 && a[i]<=100)
{
gradeCt[0]+=a[i];
}
else if(a[i]>=80 && a[i]<=89)
{
gradeCt[1]+=a[i];
}
else if(a[i]>=70 && a[i]<=79)
{
gradeCt[2]+=a[i];
}
else if(a[i]>=60 && a[i]<=69)
{
gradeCt[3]+=a[i];
}
}
//for loop over the entire array
//inside the for loop add to the
//group count
//end for loop
//display totals from gradeCt array
System.out.println(\"\ Total grade between 60 and 69 is \"+gradeCt[0]);
System.out.println(\"Total grade between 70 and 79 is \"+gradeCt[1]);
System.out.println(\"Total grade between 80 and 89 is \"+gradeCt[2]);
System.out.println(\"Total grade between 90 and 100 is \"+gradeCt[3]);
}
public static void main(String args[]) {
int grades[] = new int[10]; //set array size
//populate the array
grades[0] = 90;
grades[1] = 50;
grades[2] = 100;
grades[3] = 0;
grades[4] = 10;
grades[5] = 66;
grades[6] = 78;
grades[7] = 99;
grades[8] = 86;
grades[9] = 85;
frequency(grades,grades.length);
}
}
__________________________________________
Output:
No of grades between 90 and 100 are:3
No of grades between 80 and 89 are:2
No of grades between 70 and 79 are:1
No of grades between 60 and 69 are:1
Total grade between 60 and 69 is 289
Total grade between 70 and 79 is 171
Total grade between 80 and 89 is 78
Total grade between 90 and 100 is 66
______________Thank You

