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
Nastasia [14]
3 years ago
8

Write Java code that creates an array of n integers myArray, by taking n integers from the user with duplications, and do the fo

llowing:
1- Print the elements of myArray,
2- Calculate the sum and the mean of myArray elements,
3- Copy the values of myArray to an array list named myArrayList, the array list must contain the elements of myArray without duplication,
4- Calculate the sum and the mean of myArrayList elem
Computers and Technology
1 answer:
skad [1K]3 years ago
3 0

Answer:

this should be what you need

Explanation:

import java.util.*;

public class ABC{

 public static void main(String[] args) {

   int n;

   //create scanner object

   Scanner sc = new Scanner(System.in);

   //ask for size of array

   System.out.print("Enter the size of array (n): ");

   //read the input

   n = sc.nextInt();

   //create an array of n length

   int [] myArray = new int[n];

   //ask user for array elements

   System.out.printf("Enter %d integers: ", n);

   //read array elements

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

     myArray[i] = sc.nextInt();

   

   //print the elements if myArray

   System.out.print("1 - The values of myArray are: [");

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

     System.out.print(myArray[i]);

     if(i < n-1)

       System.out.print(", ");

   }

   System.out.print("]\n");

   //calculate mean and sum of myArray elements

   int sum = 0;

   double mean = 0;

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

     sum += myArray[i];

   

   mean = (sum*1.0)/n;

   //print the sum and mean of myArray

   System.out.printf("2 - The sum is: %d. The mean is: %.1f\n", sum, mean);

     

   //create an arraylist

   ArrayList<Integer> myArrayList = new ArrayList<Integer>();

   //copy the value of myArray to an arraylist without duplicates

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

     if(!myArrayList.contains(myArray[i]))

       myArrayList.add(myArray[i]);

   }

   sum = 0; mean = 0;

   //display the values of myArrayList

   System.out.print("3 - The values of myArrayList are: [");

   for(int i =0 ; i < myArrayList.size(); i++){

     System.out.print(myArrayList.get(i));

     if(i < myArrayList.size()-1)

       System.out.print(", ");

   }

   System.out.print("]\n");

   //calculate sum and mean of myArrayList elements

   for(int i = 0; i < myArrayList.size(); i++)

     sum += myArrayList.get(i);

   mean = (sum*1.0)/myArrayList.size();

   //print the sum and mean of myArrayList

   System.out.printf("4 - The sum is: %d. The mean is: %.2f\n", sum, mean);

 }

}

You might be interested in
U GET BRAINLIEST HELP PLZ
Art [367]
BOTH OF THEM ARE C : )
3 0
3 years ago
PLEASE HELP ME ON THIS what is the slide sorter used f or? A. viewing presentation notes B. editing the slide content C. changin
Oduvanchick [21]
I use PowerPoint a lot and C would be correct
7 0
3 years ago
If an external server needs to communicate with servers inside the green zone, which network setting on smoothwall can be opened
astraxan [27]

The network setting on the smooth wall that can be opened when the external server has the need to communicate with the servers inside the green zone is the DMS±pinholes as the pinhole will be opened with the use of the DMZ and to the green zone.

3 0
4 years ago
Read 2 more answers
Reference variables allow arguments to be passed by ____________.
son4ous [18]

Answer:

Reference

Explanation:

The Reference type variable is such type of variable in C# that holds the reference of memory address instead of value. Examples for reference type are classes, interfaces, delegates and arrays.

We can pass parameters to the method by reference using <em>ref </em>keyword

It’s mandatory to initialize the variable value before we pass it as an argument to the method in c#

For example,

int x = 10;  // Variable need to be initialized

Add(ref x); // method call

If you pass parameters by reference in method definition, any changes made to it affect the other variable in method call.

Here's a sample program:

using System;

namespace ConsoleApplication

{

   public class Test

   {

       public static void Main()

       {

           int i = 10;

           Console.WriteLine("i=" + i);

           Add(ref i);

           Console.WriteLine("i=" + i);

           Console.ReadLine();

       }

       public static void Add( ref int j)

       {

           j = j + 10;

           Console.WriteLine("j="+j);

       }

   }

}

Output:

i=10

j=20

i=20

7 0
3 years ago
Write a detailed three page report that summarizes how data scientists are utilizing data mining to predict future trends and be
LiRa [457]

Answer: given in the explanation

Explanation:

Data mining is referred as an automated processing tool used for sorting and analyzing enormous data and information which indeed are ``aimed towards effectively identifying trends and patterns and establishing relationships to solve business problems and generate new opportunities. Furthermore data mining techniques also helps to predict what’s going to happen in the future and act accordingly to take benefit of forthcoming tendencies.

Data mining is applied to a variety of large-scale data-processing activities such as collecting, extracting, warehousing and analyzing data. It also includes decision-support applications and technologies such as business artificial intelligence and machine learning and is used in varied areas of business research such as product development, sales and marketing etc.

Data mining is for taking advantage of data to predict ;

  • Mathematical algorithms, and, data are used for predictive analytics. One can capture information, and, use it to model sales pattern, trends, and, customer behaviour
  • Data mining uses algorithms to extract, and, analyze information; discover hidden patterns
  • It uses data patterns, and, is thus closely tied to machine learning
  • Historical & current information is used to predict future trends

Data mining can be used for the following:

  • Data mining in gas & oil operations - Mining data in gas & oil operations involves committing to key technologies, and, processes; and, embracing new ways of thinking & problem-solving. Firms can use exploratory data analysis, modelling techniques & model development; approaches to put models into production
  • Big data - Performance computing & advanced analytics
  • Magic Quadrant - Evaluate 16 vendors to identify the right ones
  • Heavy reading, network analytics - Optimize network; evaluate network performance; provide targeted marketing; fine-tune capacity.

5 0
4 years ago
Other questions:
  • You discover many errors in a database table. What has been lost?
    15·2 answers
  • To join two or more objects to make a larger whole is to _____________ them.
    11·2 answers
  • Which component of the Hyper-V architecture controls all communication with the physical hardware on the computer?
    8·1 answer
  • How do you make electricity
    10·1 answer
  • The thinner the thread on the screw, the ______the force needed but the _____the distance.
    15·1 answer
  • Develop a program that implements the POLYNOMIAL ADT using the LIST ADT. The POLYNOMIAL ADT is used to represent polynomials and
    8·1 answer
  • What other kinds of toolbars exist in addition to those that are part of individual programs?
    10·1 answer
  • A service that enables a customer to build and run their own applications but doesn't include extensive access to hardware and m
    8·1 answer
  • A security event popped up, alerting security of a suspicious user gaining access to, and copying files from, the %systemroot%\n
    11·1 answer
  • In the classic experimental design, there are two groups: the _____ group and the _____ group.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!