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
OSHA requires training for employees on the hazards to which they will be exposed.
Sedaia [141]

A, OSHA does require training for employees on the hazards to which they will be exposed.


3 0
3 years ago
Read 2 more answers
Peter works on a huge database of numerical figures in a worksheet ranging from cell A1 to cell I50. He has to print the workshe
Amiraneli [1.4K]
Landscape and portrait page orientation.
4 0
2 years ago
Read 2 more answers
When widgets, or portable chunks of code, are embedded on html pages and thereby help increase the functionality of those pages,
Anna11 [10]
<span>When widgets, or portable chunks of code, are embedded on html pages and thereby help increase the functionality of those pages, consumers embrace one of the greatest virtues of social media known as Collaboration.</span>
5 0
3 years ago
A regular language can not be infinite.<br> True<br> False
Elan Coil [88]

Answer:

False

Explanation:

A regular language can be represented by a regular expression. A regular language can be infinite. Let us consider a simple example of an infinite regular language:

a* is a regular language represented by a regular expression.

The languages matches all strings containing or more a's.

Clearly this is an infinite language.

Note that all finite languages are regular but all regular languages need not be finite.

3 0
3 years ago
What is Deep learning
vodomira [7]

Answer:

Deep learning is an AI function that mimics the workings of the human brain in processing data for use in detecting objects, recognizing speech, translating languages, and making decisions. Deep learning AI is able to learn without human supervision, drawing from data that is both unstructured and unlabeled.

3 0
3 years ago
Other questions:
  • The ability of services to grow or shrink based on need is called __________.
    14·1 answer
  • How to write greater than or equal to in excel if function
    7·1 answer
  • Consider the following high-level recursive procedure: long long int flong long int n, long long int k long long int b b k+2; if
    9·1 answer
  • Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, a
    8·1 answer
  • A home user reports to a network technician that the Internet is slow. The network administrator discovers that multiple unknown
    12·2 answers
  • What is a computer and what is the work of it​
    5·2 answers
  • What is gained by increasing the ritation speed of a disk or cd?​
    9·1 answer
  • Para ti que es el sexting​
    11·1 answer
  • Which option should you choose to change the background of your current slide?
    10·2 answers
  • How do you initiate a sprite’s actions in a scene?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!