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
What are two differences between a wide angle lens and a telephoto lens?
adell [148]

Answer:

A wide-angle lens is all about wide focus it keeps the entire shot in focus regardless of distance. A telephoto lens is all about selective focus, or choosing which objects looks sharp or blurry. Wide-angle lenses generally have a longer depth of field, which means that they are not the right fit for a situation like portrait photography, where you only want the subject in sharp focus. In order to choose the right lens for your situation, you’ll need to decide how much in-focus detail you want in your shots.

Explanation:

6 0
3 years ago
Read 2 more answers
Plis is a unit test !!!!!!! HelP ASAP only 30 mins left, will mark as brainliest
7nadin3 [17]

Answer:

i. View Tab

Explanation:

View tab is used to change the current view of the document. The view can be changed as, Grid view, outline view, draft view and web layout view. This can be used to check the document from different aspects.

ii. Busy

Explanation

Whenever some one is scheduling meeting, the users saw that, busy is written in different time slots of the calendar, whenever the person is busy.

iii. Attach Signature

Explanation

When some user want to send his information, such as name, designation, contact number etc. in email. He should add his signature in the document. The signature in the mail is the information, that sender want to sent to client.

iv. All Categories

Explanation

In outlook 2016, All categories option is used to change the category name by editing this information. There are different categories represented by different colors. To change the name of the category, Haratio just choose the option of All categories.

7 0
3 years ago
In the ____________________ approach, the project is initiated by upper-level managers who issue policy, procedures and processe
FrozenT [24]

Answer:

top-Down

Explanation:

4 0
3 years ago
Pls help I will give points
Brrunno [24]

Answer:

Desktop

Explanation:

3 0
3 years ago
Part 2: a) Write VHDL code for a top module that invokes necessary components to display the four decimal digits on four seven-s
dimulka [17.4K]
I don’t know ‍♀️ sorry
7 0
3 years ago
Other questions:
  • You just brought a new hard drive for your computer. U plan to use this as a secondary hard drive to store all your uma files. O
    10·1 answer
  • What is primary storage
    11·2 answers
  • How can you keep your files organized on your computer?
    13·2 answers
  • . The toasting cycle of an automatic toaster is started by A. pushing the bread rack down. B. pushing the start button. C. turni
    14·2 answers
  • After a chart has been inserted and formatted, is it possible to change the data range it refers to or to add new rows of data?
    14·1 answer
  • In his article “is google making up stupid” Nicholas Carr uses a metaphor to suggest that
    11·2 answers
  • What do level meters show?
    8·1 answer
  • What is the best stratiget to avoid paying intrest in your credit cared
    13·1 answer
  • Question #5
    14·1 answer
  • What kind of skill is persuasion?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!