Question: Use Java Programming There are 3 versions of the ArrayProgram. All 3 versions of this program, calculate the sum, average, largest, and smallest elements of

Use Java Programming

There are 3 versions of the ArrayProgram. All 3 versions of this program, calculate the sum, average, largest, and smallest elements of an array. Pick the one that you like best. Add logic inside the for loop to test if the number is between 90 and 100. If the number is in this range, then it should add 1 to the tally of gradeA. You should have another test to see if the number is between 80 and 89 and if it is it should add 1 to the tally of gradeB. You should continue to have tests for 70 to79 being gradeC; 60-69 being graded; and below 60 as being gradeF. After the for loop is done, you should display a list of how many students had A's, B's, etc. in the output message box.

If the data is:

90 100 80 85 63 73 80 92 90

The display should be something like this:

The sum is 753

The average is 83

The largest test score is 100

The lowest test score is 63

The number of students with scores of 90-100 (A) is 4

The number of students with scores of 80-89 (B) is 3

The number of students with scores of 70-79 (C) is 1

The number of students with scores of 60-69 (D) is 1

The number of students with scores below 60 (F) is 0

Rubric:

Set the variables of gradeA, gradeB, gradeC, gradeD, and gradeF to zero at beginning of program.

Set up the 5 if statements appropriately to count the gradeA, gradeB, gradeC, gradeD, and gradeF variables

Print the counts for each grade in a message box.

This is what I got but I couldn't get display what I want to get plese help me out.

import java.util.*;

class Array2{

public static void main(String[] args){

int num;

Scanner s=new Scanner(System.in);

System.out.println("enter the number of elements");

num=s.nextInt();

int arr=new array[num];

for(int i=0;i

arr[i]=s.nextInt();

//sum,average,lowest,highest

int min=arr[0],max=arr[1],sum=0,gradeA=0,gradeB=0,gradeC=0,gradeD=0,gradeF=0;

for(int i : arr)

{

if(min>arr[i])

min=arr[i];

if(max

max=arr[i];

sum=sum+arr[i];

if(arr[i]<60)

gradeF++;

else if( arr[i]>59 && arr[i] <70)

gradeD++;

else if (arr[i]>69 && arr[i]<80)

gradeC++;

else if (arr[i]>79 && arr[i]<90)

gradeB++;

else if (arr[i]>89arr[i]<100)

gradeA++;

}

}

System.out.println("the sum is %d"+sum);

System.out.println("the average is %f"+sum/num);

System.out.println("the largest elements is %d"+max);

System.out.println("the smallest element is %d"+min);

System.out.println("the number of students with the scores of 90-99(A) %d"+gradeA);

System.out.println("the number of students with the scores of 80-89 (B) %d"+gradeB);

System.out.println("the number of students with the scores of 70-79(C) %d"+gradeC);

System.out.println("the number of students with the scores of 60-69(D) %d"+gradeD);

System.out.println("the number of students with the scores of below 60 (F)"+gradeF);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!