1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ohaa [14]
3 years ago
13

Write a program that:

Computers and Technology
1 answer:
gregori [183]3 years ago
4 0

Answer:

The Java code is given below with appropriate comments for better understanding

Explanation:

//DataAnalyzer.java

import java.util.*;

class DataAnalyzer

{

  private LinkedList<Integer> numbers;

  //Parameterized Constructor that stores the list of numbers

  public DataAnalyzer(LinkedList<Integer> numList)

  {

      //Storing numList to numbers

      numbers = numList;

  }

  //Implementation of min() method that returns minimum number

  public int min()

  {

      //consider starting number is the minimum number

      int minNum = numbers.get(0);

      //Iterate the numbers in the list

      for(int j=0; j < numbers.size(); j++)

      {

          //Comparing each number with minNum

          if( numbers.get(j) < minNum )

              //Update minimum number

              minNum = numbers.get(j);

      }

      //Return minimum number of the list

      return minNum;

  }

  //Implementation of max() method which returns maximum number

  public int max()

  {

      //consider starting number is the max number

      int maxNum = numbers.get(0);

      //Iterate the numbers in the list

      for(int j=0; j < numbers.size(); j++)

      {

          //Comparing each number with maxNum

          if( numbers.get(j) > maxNum )

              //Update maximum number

              maxNum = numbers.get(j);

      }

     

      //Return maximum number of the list

      return maxNum;

  }

  //Implementation of average() method returns average of all numbers

  public double average()

  {

       //Declare sum as type of integer and assign value as zero

      int sum = 0;

      //Declare avg as type of double type

      double avg;

     

      //Iterate the numbers in the list

      for(int j=0; j < numbers.size(); j++)

      {

          //add sum of numbers

          sum = sum + numbers.get(j);

      }

     

      avg = sum / (double)(numbers.size());

      //Return average value of the list

      return avg;

  }

}

DataAnalyzerTester.java

//DataAnalyzerTester.java

import java.util.*;

import java.io.*;

//Implementation of DataAnalyzetTester class

class DataAnalyzerTester

{

  //Main method

  public static void main(String args[])

  {

      try

      {

          //Declare numList as variable of type

      //Linked list that store user input

          LinkedList<Integer> numList = new LinkedList<Integer>();

          int num;

     

          //Declare Scanner class object

          Scanner input = new Scanner(System.in);

          String fileName;

          //Display statement

          System.out.print("\n Enter file name for storing numbers: ");

          fileName = input.nextLine();

         

          //Create a variable as file type

          File createfile = new File(fileName);

          //Creating file

          createfile.createNewFile();

          //Creating a FileWriter Object

          FileWriter writer = new FileWriter(createfile);

         

          System.out.println("\n Start entering numbers (0 to stop): \n\n");

     

          //Reading number

          num = input.nextInt();

     

          //Iterate the loop

          //until user enters 0

          while(num != 0)

          {

              //Writing numbers to the file

              writer.write(num + " \n ");

             

              //Add those numbers to list

              numList.add(num);

              //Get another number from user

              num = input.nextInt();

          }

          //Creating DataAnalyzer object

          DataAnalyzer analyzerObject = new DataAnalyzer(numList);

          //Display statement for min, max and average values

          System.out.println("\n\n Minimum Number: " + analyzerObject.min());

          writer.write("\n\n Minimum Number: " + analyzerObject.min());

          System.out.println("\n\n Maximum Number: " + analyzerObject.max());

          writer.write("\n\n Maximum Number: " + analyzerObject.max());

          System.out.println("\n\n Average: " + analyzerObject.average() + " \n\n");

          writer.write("\n\n Average: " + analyzerObject.average() + " \n\n");

         

          writer.flush();

         

          //Close the file object

          writer.close();

      }

     

      catch(Exception ex)

      {

      //display statement

          System.out.println(ex);

      }

  }

}

You might be interested in
Which of the following best describes a hacktivist? Select one: a. An individual who attempts to destroy the infrastructure comp
brilliants [131]

Answer: (B) An individual who hacks computers or Web sites in an attempt to promote a political ideology

Explanation:

 Hacktivist is the defined as an individual that basically hacks the various types of web sites and computer system for promoting the various political ideologies. The hacktivists is the method which include the DDOS attacks (Distributed denial of services).

It basically causes various website and the email with the congestion of traffic with the computer virus and by the data stealing. The denial of services attacks typically considered federal crime and illegal in united state.  

4 0
4 years ago
What subnet mask can be used to segment the 172.16.0.0 network to allow for a minimum of 6 subnets while maximizing the number o
marishachu [46]

The subnet mask can be utilized to segment the 172.16.0.0 network to qualify for a minimum of 6 subnets while maximizing the numeral of broadcasters per subnet is 255.255.224.0

<h3>What do subnet masks mean?</h3>
  • A subnet mask is a 32-bit numeral formed by setting keeper bits to all 0s and developing network times to all 1s.
  • In this way, the subnet mask divides the IP speech into the network and host addresses.
  • A subnet mask is used to separate an IP address into two pieces. One element defines the host (computer), and the different part identifies the network to which it belongs.
  • To better comprehend how IP lessons and subnet masks work, look at an IP speech and see how it's managed.

To learn more about  subnet mask, refer to:

brainly.com/question/3234986

#SPJ4

5 0
2 years ago
Home
Papessa [141]

Answer:

Enables online download of music

Enables reading while exercising

Reduces the need for printing

Enables sending documents to multiple recipients

Provides savings on travel expenses by supporting virtual meetings

Provides flexible work schedules and environments

Explanation:

7 0
4 years ago
Give sally sue specific suggestions on how she can improve her powerpoint skills.
castortr0y [4]
Use proper words. Also, add interesting facts about the subject
5 0
3 years ago
Lesson 1 (4.0 points)
sesenic [268]


3. Hold down the CTRL, ALT, and DELETE keys simultaneously, click Task Manager option, then right-click the frozen program's name, and finally click the end task button.


8 0
3 years ago
Read 2 more answers
Other questions:
  • Which spereadsheet type will determine<br> how well a bussiness has done over the past year
    11·1 answer
  • Proxy data:
    12·1 answer
  • Manuel is working on a project in Visual Studio. He wants to keep this program showing on the entire desktop, but he also needs
    13·1 answer
  • What are some activities that work especially well in Outline view? Check all that apply.
    5·2 answers
  • Given the following code fragment and the input value of 4.0, what output is generated?
    8·1 answer
  • Which of the following statements is used to terminate the program when closing the frame?
    12·1 answer
  • Harry is creating a PowerPoint presentation and wants all the slides to have a uniform look.
    8·1 answer
  • Create a Python script that takes two parameters to do the following:-
    9·1 answer
  • Which of the following is true of equilibrium? *
    9·1 answer
  • What sets Web pages apart from other documents is that they contain a special kind of text called ___, which is document text th
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!