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
Explain different types of secondary memory of computer system<br>​
Westkost [7]

<em>Answer:</em>

<em>There are three main types of secondary storage in a computer system: solid state storage devices, such as USB memory sticks. optical storage devices, such as CD, DVD and Blu-ray discs. magnetic storage devices, such as hard disk drives.</em>

<em>Explanation:</em>

6 0
2 years ago
Suppose that a queue is implemented using a circular array of size 12. What is the value of last after the following operations?
otez555 [7]

Answer:

10

Explanation:

An enqueue operation is a function that adds an element(value) to a queue array. A dequeue operations removes an element from a queue array. Queue arrays follow a first-in-first-out approach, so elements that are first stored in the queue are removed/accessed first(enqueue operations add elements at the rear of the queue array).

The following operations leave 10 elements in the queue of array size 12 after its done:

10 enqueue operations= adds 10 elements

5 dequeue operations= removes 5 elements( 5 elements left in queue)

6 enqueue operations= adds 6 elements(11 elements in queue)

10 dequeue operations= removes 10 elements(1 element left in queue)

8 enqueue operations= adds 8 elements(9 elements in queue)

2 dequeue operations= removes 2 elements(7 elements left in queue)

3 enqueue operations= adds 3 elements(10 elements in queue)

Therefore there are 10 elements in the queue after enqueue and dequeue operations.

8 0
3 years ago
4.15 LAB: Password modifier
Black_prince [1.1K]

I've included my code in the picture below. Best of luck.

3 0
3 years ago
______A computer program may only be constructed in a high level language. (T/F)
NeTakaya

Answer:

False.

Explanation:

A computer program can not only constructed in a high level language but also in low level language such as assembly language used for microprocessor for ex-8085 microprocessor,8086 microprocessor ,ARM assembly language and there are many more.

High level languages are programmer friendly they are easily understood by the programmers because they uses english words while low level languages are difficult because they uses binary language 0's or 1's.

Hence the answer to this question is False.

5 0
3 years ago
Privacy settings allow account owners to decide who can ........
schepotkina [342]
Have access to your phone info
4 0
3 years ago
Read 2 more answers
Other questions:
  • Which term defines a star system with two stars?
    13·2 answers
  • You can choose to use a window manager only, and not use a desktop manager.
    8·2 answers
  • Declare an array reference variable, week, and initialize it to an array containing the strings "mon", "tue", "wed", "thu", "fri
    15·1 answer
  • What is one reason to create a study check list​
    7·1 answer
  • Write a program that prints the following text: In C, lowercase letters are significant. main() is where program execution begin
    14·1 answer
  • KeyonnnKeyonnnKeyonnnKeyonnnKeyonnnKeyonnnKeyonnnKeyonnnKeyonnnKeyonnnKeyonnnKeyonnnKeyonnnKeyonnnKeyonnnKeyonnnKeyonnnKeyonnnKe
    8·2 answers
  • What is a header row?
    8·1 answer
  • Globalization is based on <br>​
    10·1 answer
  • Choose ALL guidelines listed below pertaining to fair use.
    12·2 answers
  • Which device allows users to directly hear data from a computer
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!