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

write a program that creates an array of 10 integers the program should then use

ID: 3861403 • Letter: W

Question

write a program that creates an array of 10 integers the program should then use the following functions.

write a Statistical Analysis program that creates an array of 10 integers. The program should then use the following functions: main out getData() Used to ask the user for the numbers and store them into an array display Data Used to display the data in the array. display Largest used to find and display the largest number in the array. display smallest() Used to find and display the smallest number in the array. display Average Used to find and display the average of the numbers in the array. Gre display Range() Used to find and display the range of numbers in the array. display Mode used to find and display the mode of numbers in the array sea ch You may **display Median Used to find and display the median value in the array. (Extra Credit!) 3 not use any global variables. You must use a defined constant (#define MAx 10) and use this constant in your code. Your code must work well for both an even number and an odd number of integers. Dont Dever verable on tside main Show Me!

Explanation / Answer

import java.applet.Applet;

import java.awt.Graphics;

import java.awt.*;

import java.awt.event.*;

public class HelloWorld{

int arr[]={1,2,3,4,5,6,7,8,9,10};

public int getData(int[] arrayOfInts, int index) {

    return arrayOfInts[index];

}

public void display(){

    

     for (int i=0;i<arr.length-1;i++){

        

         System.out.println("display the array elements are:"+arr[i]);

        

     }

}

public static void main(String[] args)

{

    HelloWorld hw= new HelloWorld();

    int arr[]={1,2,3,4,5,6,7,8,9,10};

   

    getData(9,10);

    //int arr[]={1,2,3,4,5,6,7,8,9,10};

   

}

void displaylargestvalue(){

System.out.println("Enter elements of array:");//largest method

        for(int i = 0; i < n; i++)

        {

            a[i] = s.nextInt();

        }

        max = a[0];

        for(int i = 0; i < n; i++)

        {

            if(max < a[i])

            {

                max = a[i];

            }

        }

        System.out.println("Maximum value:"+max);

}

      void displaysmallest(){

        for (int c = 0;c<array.length;c++)// smallest value

    {

    array[c] = input.nextDouble();

    }

    min(array);

    double min(double[] array)

    {

    int i;

    double min = array[0];

    for(i = 1; i < array.length; i++)

     {

    if(min > array[i])

      {

    min = array[i];

      }

     }}

     void displayy(){

      for(int i=0; i < numbers.length ; i++) // average method

                        sum = sum + numbers[i];

               

                //calculate average value

                double average = sum / numbers.length;

              

                System.out.println("Average value of array elements is : " + average);

     }

     void displayrang(){

          int min = 0;//display range

    int max = 0;

    int range = 0;

for (int i: list)

    {

       if (list.size() > 0)

        {

         range = max - min + 1;

        }

    }

      return range;

     }

     void displaymode(){

         Arrays.sort(n);

   

    int count2 = 0;

    int count1 = 0;

    int pupular1 =0;

    int popular2 =0;

    for (int i = 0; i < n.length; i++)

    {

            pupular1 = n[i];

            count1 = 0;    //see edit

        for (int j = i + 1; j < n.length; j++)

        {

          if (pupular1 == n[j]) count1++;

        }

        if (count1 > count2)

        {

                popular2 = pupular1;

                count2 = count1;

        }

        else if(count1 == count2)

        {

            popular2 = Math.min(popular2, pupular1);

        }

    }

    return popular2;

}

     }

    

     void meridan(){

         Label label;

    TextField input;

    int num;

    int index;

    int[] numArray = new int[20];

    int sum;

    int total;

    double avg;

    int median;

    public void init ()

    {

        label = new Label("Enter numbers");

        input = new TextField(5);

        add(label);

        add(input);

        input.addActionListener(this);

        index = 0;

    }

    public void actionPerformed (ActionEvent ev)

    {

        int num = Integer.parseInt(input.getText());

        numArray[index] = num;

        index++;

        if (index == 20)

        input.setEnabled(false);

            input.setText("");

        sum = 0;

        for (int i = 0; i < numArray.length; i++)

        {

            sum += numArray[i];

        }

        total = sum;

        avg = total / index;

        median = numArray[numArray.length/2];

    }

     }

}