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
Design a program that will ask the user to enter the amount of a purchase. The program
LUCKY_DIMON [66]

The program is a sequential program, and they do not require loops and conditions

<h3>The program design in Python</h3>

The complete program written in Python is as follows:

purchaseAmount = float(input("Amount: "))

stateSalesTax = 0.05 * purchaseAmount

provincialSalesTax = 0.02 * purchaseAmount

print("Amount:",purchaseAmount)

print("State sales tax:",stateSalesTax)

print("Provincial sales tax:",provincialSalesTax)

print("Total sales tax:",(stateSalesTax + provincialSalesTax))

print("Total sales:",(purchaseAmount + stateSalesTax + provincialSalesTax))

Read more about Python programs at:

brainly.com/question/26497128

#SPJ1

4 0
3 years ago
A skillful response consist of two parts: affirmation andanswer<br><br> True<br><br> False
antoniya [11.8K]

Answer: False

Explanation:

A skillful response is defined as, answering the response in a skillful manner with all the technical and skillful approach. Firstly, read the question carefully and answer according in a proper format manner. Affirmation and answer are not enough for the skillful response as, it also include various kinds of approach like it should be error free and declaration of the answer should be in format, meaningful and proficient.

7 0
3 years ago
The ListCell subclass’s ________ method creates the custom presentation. This method is called by the ListView’s cell factory wh
Vlada [557]

Answer:

A

Explanation:

Update

The listview can be called an arbitrary amount of times, different items may be passed and the cell can go from empty to non-empty and the other way round. ListView creates about as many cells as you see on screen and fills them with items. E.g. scrolling or modifications of the items list or resizing of the ListView can result in updates.

7 0
3 years ago
__________ is the backbone of a computer, connecting all of its components including the central processing unit (CPU) and prima
Tems11 [23]
It’s D. The microprocessor
5 0
3 years ago
Select below the Active Directory server role that provides the functions of Active Directory without the requirements of forest
sasho [114]

Answer:

​AD DS

Explanation:

Active Directory Domain Service is an active directory server role found in windows server and it permits admins in a network environment store and also manages information from a particular source in a network, there are no requirements for forests, domains, and domain controllers. It works both on intranet and internet networks.

3 0
4 years ago
Other questions:
  • The tiny memory cards used by digital cameras and mobile devices are an example of ____ storage.
    15·1 answer
  • Editing and sorting the data file are steps performed during the ________ stage in the data processing cycle
    5·1 answer
  • What sequence would a user need to follow to change Chart A into Chart B?
    11·1 answer
  • A folder can contain only files? A. True B.False
    10·2 answers
  • What is the answer to this question?
    10·1 answer
  • The Android operating system was invented by ______.
    13·1 answer
  • 20 points
    5·1 answer
  • Which of the following is an example of metadata about a webpage?
    7·2 answers
  • Está dentro del gabinete del CPU es electrónica y hace que la transferencia de datos se realice contra gran rapidez / ayuda vien
    6·1 answer
  • When we connect to a story, it can be mental, emotional, or even physical. <br> True or False?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!