i need to make changes to the code below with these requirements Rewrite Assignm
ID: 3646655 • Letter: I
Question
i need to make changes to the code below with these requirementsRewrite Assignment using Java Class implementation. Name your class MyClass. Create all necessary functions and constructors. Write your own main() program to test and verify that your class works.
Write an application program that reads in a list of integer numbers and print out the sum of all numbers, the average, the lowest and the highest value entered. The first input number indicates how many numbers the program is going to read. For example, if the first number entered is 5, then it means five integer numbers will be expected as input. Display your result in an output dialog box.
Run/test you program with at least 5 input numbers.
code
//will ask user how many intergers user wants to enter and it will store it into an array and then based on how many number the integers entered it will ask user to
// enter integers one by one
//Ankit Patel
//filename: array.java
import java.io.*;
import javax.swing.JOptionPane;
class array
{
public static void main(String args[])
{
String firstNumber;
int i=0,size;
float average=0,sum=0;
firstNumber =JOptionPane.showInputDialog ( "Enter the number of integers" );
size=Integer.parseInt ( firstNumber);
int a[]=new int[size];
for(i=0;i<size;i++)
a[i]=Integer.parseInt
(JOptionPane.showInputDialog
( "Enter the values" ));
int min=a[0],max=a[0];
for(i=0 ;i<size;i++)
{
sum=sum+a[i];
if(a[i]<min)
min=a[i];
if(a[i]>max)
max=a[i];
}
average=(sum/size);
JOptionPane.showMessageDialog(null,"result: sum"+sum+" min:"+min+" max:"+max+" average:"+average);
}
}
Explanation / Answer
CORRECT PROGRAM: import java.io.*; import javax.swing.JOptionPane; class MyClass { public static void main(String args[]) { String firstNumber; int i=0,size; float average=0,sum=0; firstNumber =JOptionPane.showInputDialog ( "Enter the number of integers" ); size=Integer.parseInt ( firstNumber); int a[]=new int[size]; for(i=0;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.