Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

7 Subscriptions Yo × v O Monster Hunter: wor x My eBay Summary × Watch wwE Smack

ID: 3878798 • Letter: 7

Question

7 Subscriptions Yo × v O Monster Hunter: wor x My eBay Summary × Watch wwE Smack WX Class Materials-co D Computer Organizatio X Secure l https://blackboard.kean .edu/bbcswebdav/pid-730905-dt-content-rid-2774461,1/courses/18SP-CPS-2231-06/2b-Chapter6-Part2%281%29.pdf |w.eN 0 eduardo C Class exercise -30 minutes Write a program that does the following: Prompt the user for the number of test grades to be entered - In a loop, get the test grades from the user and calculate - Call a method: public static void printAverage(double sum, int numTests) the sum. which prints the average of the tests. 25

Explanation / Answer

import java.util.scanner;
class AverageMarks
{
public static void main(String args[])
{

int i;

System.out.println("How many grades?");

Scanner sc=new Scanner(System.in);

int n=sc.nextInt();

int[] a=new int[n];

double avg=0;

System.out.println("Enter "+n+" grades");

for( i=0;i<n;i++)
{
a[i]=sc.nextInt();
}

for( i=0;i<n;i++)
{
avg=avg+a[i];
}

System.out.print("Average is "+avg/n");


}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote