
Write a Java application that can capture five or more numbers and returns the total of the numbers, the average and the difference between total and average using input dialogs

import javax.swing.*;
class NumberExample3
{
public static void main(String[] args)
{
int num[]=new int[5];
int sum=0;
for(int i=0;i<num.length;i++){
int number=Integer.parseInt(JOptionPane.showInputDialog(null, "Enter Number: "+(i+1)));
num[i]=number;
sum+=num[i];
}
JOptionPane.showMessageDialog(null,"Sum of Numbers: "+(Integer.toString(sum)));
int avg=sum/num.length;
JOptionPane.showMessageDialog(null,"Avergae of Numbers: "+(Integer.toString(avg)));
int diff=sum-avg;
JOptionPane.showMessageDialog(null,"Difference between sum and average: "+(Integer.toString(diff)));
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.