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

Write a Java program to input the following integer numbers into an array named

ID: 3660063 • Letter: W

Question

Write a Java program to input the following integer numbers into an array named grades: 89, 95, 72, 83, 99, 54, 86, 75, 92, 73, 79, 75, 82, 73. As each number is input, add the number to a total. After all numbers are input and the total is obtained, calculate the average of the numbers and use the average to determine the deviation of each value from the average. Store each deviation in an array named deviation. Each deviation is obtained as the element values less the average of all the data. Have your program display each deviation alongside its corresponding element from the grades array.

Explanation / Answer

please rate - thanks


import javax.swing.*;
public class main
{
public static void main(String []args)
{int total=0,n,i;
double average;
String input,output;
input= JOptionPane.showInputDialog(null,"How many numbers do you have? ");
n=Integer.parseInt(input);
int [] grades= new int[n];
double []deviation=new double[n];
for(i=0;i<n;i++)
     {input= JOptionPane.showInputDialog(null,"Enter number "+(i+1)+": ");
      grades[i]=Integer.parseInt(input);
        total+=grades[i];
        }
average=(double)total/n;
for(i=0;i<n;i++)
     deviation[i]=grades[i]-average;
output=("element   grade    deviation ");
for(i=0;i<n;i++)
   output=output+(i+1)+"               "+grades[i]+"            "+deviation[i]+" ";   
JOptionPane.showMessageDialog(null,output);   
}
}

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