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
Professional photography is a competitive job field. <br> true <br> false
Vika [28.1K]

Answer:

True

Explanation:

5 0
3 years ago
Read 2 more answers
A Homecoming Crossword Puzzle
nasty-shy [4]

Answer:

Umm do you need ideas for that? Like words for it?

Explanation:

6 0
3 years ago
Match letters from column B to Column A by looking at the picture above.
yarga [219]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

This question is about mapping correct terms with their number in the given picture. The correct matching of Column A and Column B is given below

Column A                               Column B

Horizontal axis                        3

Legend                                    4

Vertical axis                             2

Chart Data                               1

5 0
4 years ago
For which of the following values of A and B will the expression A || B be true?
Blababa [14]

Answer:

A = False, B = True

Explanation:

|| is equal OR. To the expression be true, you need one of them to be true or both.

A = TRUE, B = FALSE

Returns true

A = FALSE, B = FALSE

Returns true

A = TRUE, B = TRUE

Returns true

7 0
3 years ago
Mike wants to build an amplifier. which technology can he use?
STatiana [176]
A.
Not B because a guitar has no moving parts.
Not C because guitars receive all the power they need from a cord.
And not D because a guitar is not a car and doesn't need to move!
4 0
3 years ago
Other questions:
  • Which of the following is not a thing needed to make a network?
    6·2 answers
  • Which of the following refers to special eyeglasses from Google that provide the user with visual information directly in front
    5·1 answer
  • A dual-core processor is like having two processors in one.<br> -True<br> -False
    6·1 answer
  • _____________ helps to control and limit the number of consecutive request failures that cross a threshold. Review breaker Micro
    7·1 answer
  • Instructions (software) that allow a computer (hardware) to be used are written using specific symbols, letters and numbers know
    7·1 answer
  • Assume user_name equals "Tom" and user_age equals 22. What is printed on the console when the following statement is executed? c
    14·1 answer
  • Write a method intersect that accepts two sorted array lists of integers as parameters and returns a new list that contains only
    8·1 answer
  • What is the missing line of code?
    13·1 answer
  • True or false As the contents and topics of new magazines change year-to-year, you can see various trends and movements across s
    15·1 answer
  • You’ve been tossed into an insane asylum. What do you tell the people there to prove to them that you don’t belong inside?
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!