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
natka813 [3]
3 years ago
12

Write a java program to read elements in an array from user and count total number of duplicate elements in array.

Computers and Technology
1 answer:
Anna11 [10]3 years ago
8 0

Answer:

Explanation:

The following code is written in Java and is a function/method that takes in an int array as a parameter. The type of array can be changed. The function then creates a counter and loops through each element in the array comparing each one, whenever one element is found to be a duplicate it increases the counter by 1 and moves on to the next element in the array. Finally, it prints out the number of duplicates.

public static int countDuplicate (int[] arr) {

               int count = 0;

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

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

                               if(arr[i] == arr[j])

                                       count++;

                       }

               }

               return count;

       }

You might be interested in
Which of the following is the core of an operating system that maintains the computer’s clock, starts applications, and assigns
bagirrra123 [75]
The answer is the Kernel.
In computing, the Kernel's job is to manage the I/O requests from the software on your computer and converts them into data processing instructions for the CPU (Central Processing Unit) and the rest of the electronic components of a computer.
 
4 0
3 years ago
LIST THE BEST 10 3D PRINTERS WITH THEIR RESPECTIVE APPLICATION SOFTWARES.
Yakvenalex [24]

Answer:

Epson

Explanation:

7 0
2 years ago
Read 2 more answers
Which class members should be declared as public?
yawa3891 [41]

Answer:

B. Methods and occasionally final attributes

Explanation:

In Computer programming, class members can be defined as the members of a class that typically represents or indicates the behavior and data contained in a class.

Basically, the members of a class are declared in a class, as well as all classes in its inheritance hierarchy except for destructors and constructors.

In a class, member variables are mainly known as its attributes while its member function are seldomly referred to as its methods or behaviors.

One of the main benefits and importance of using classes is that classes helps to protect and safely guard their member variables and methods by controlling access from other objects.

Therefore, the class members which should be declared as public are methods and occasionally final attributes because a public access modifier can be accessed from anywhere such as within the current or external assembly, as there are no restrictions on its access.

6 0
3 years ago
What is the result of the following code?<br><br> x=7//2+10%2**4<br><br> print(x)
spin [16.1K]

Answer:

3

Explanation:

We can split the expression into two sections

First Section:

7 // 2 = 3. Using the floor division we only utilize the integer part.

Second Section:

10 % 2**4 = 0**4 = 0

Bringing back the full version expression we have

3 + 0 = 3

7 0
2 years ago
Why should we learn Ethereum? Explain.
Licemer1 [7]

Answer:

<h3><em>Ethereum Benefits</em></h3><h3><em>It has a large and committed global community and the largest ecosystem in blockchain and cryptocurrency. Wide range of functions. Besides being used as a digital currency, Ethereum can also process other financial transactions, execute smart contracts and store data for third-party applications.</em></h3>

Explanation:

<h3><em>Hope this helps and mark as a brianliest</em></h3>
7 0
2 years ago
Other questions:
  • ¿Es especial que mi cumpleaños sea el día de San Valentín?<br><br> si o no
    11·2 answers
  • Jemima is reviewing her history report and notices that her headings are not formatted the same throughout the
    7·1 answer
  • Assuming the Direct Hashing function and the Subtraction preprocessing algorithm is used to map keys into indices, give the inde
    15·1 answer
  • What are the characteristics of good blogs?
    8·1 answer
  • Random Access Memory is tempory computer memory that stores works in progress
    7·1 answer
  • Which page in a web site do viewers usually see first?
    15·1 answer
  • How do you remove management from your chrome book [administrator]
    12·1 answer
  • Please answer me <br> in Assignment - Algorithms
    10·1 answer
  • what is a program or collection of programs that enable a person to manipulate a visual images on a computer​
    14·1 answer
  • A eclipse occurs at a full moon when the moon passes between earth and the sun
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!