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
What OC level is primarily used as a regional isp backbone, and occasionally by very large hospitals, universities, or other maj
Neporo4naja [7]

The OC level is primarily used as a regional ISP backbone, and occasionally by very large hospitals, universities, or other major enterprises is <u>OC-48.</u>

<u></u>

<h3>What is the greatest amount of throughput provided by an OC 12?</h3>

OC-12 is a network line with communication speeds of up to 622.08 Mbit/s (payload: 601.344 Mbit/s; overhead: 20.736 Mbit/s). OC-12 lines are generally used by ISPs as wide area network (WAN) connections.

<h3>When using frame relay What is the appellation of the identifier?</h3>

A data-link connection identifier (DLCI) determines the Frame Relay PVC. Frames are routed through one or more virtual circuits determined by DLCIs.

Each DLCI has a permanently configured switching path to a particular destination

To learn more about OC level , refer

brainly.com/question/25899244

#SPJ4

<u></u>

5 0
1 year ago
Which site had a major influence on the social gaming site Friendster?
Oduvanchick [21]
The answer is, "Ryze".
4 0
3 years ago
Read 2 more answers
Brad, a project manager, wants to build a database to integrate information about employees and tasks that they handle. Brad wan
zhuklara [117]

Answer:

entities

Explanation:

3 0
3 years ago
Create a Racket procedure compute_pos that reads numbers from the keyboard until 0 is read, count how many positive numbers are
Artyom0805 [142]

Answer:

import java.util.Scanner;

public class Solution {

   public static void main(String args[]) {

       compute_pos();

     }

     

     public static void compute_pos(){

     Scanner scan = new Scanner(System.in);

     int sum = 0;

     int counter = 0;

     // Prompt the user to enter an input

     System.out.println("Enter your value");

     // user input is assign to the variable value

     int value = scan.nextInt();

     

     while(value != 0){

         if (value > 0){

             sum += value;

             counter++;

         }

         System.out.println("Enter your value");

         value = scan.nextInt();

     }

     // Display the value of sum to the user

     System.out.println("The sum of the positive number is: " + sum);

     // Display the value of counter to the user

     System.out.println("The number of positive number is: " + counter);

   }

}

Explanation:

The first line import the Scanner class which allow the program to read input from the user. The class Solution is then defined. Then the main method which signify the beginning of execution in the program is defined. A method is called inside the main method.

The method compute_pos is defined. Inside the compute_pos method, a scanner object scan is declared to accept input from the user via the keyboard.

The variable sum and counter is declared and assigned to 0.

A prompt is displayed to the user to input a value. The user input is accepted and stored in the variable value.

Then a while loop is use to check the user input if it is not equal to zero. If it is equal to zero, the loop will end. Inside the loop, we first check to see if the user input is greater than 0, if it is, we add it to the variable sum and increase our counter by 1. At the end of the loop, a prompt is again display to accept input from the user.

Outside the loop, we display the sum and counter to the user.

8 0
3 years ago
A major weakness of a lot of file processing systems is that ____.
Gnesinka [82]

They are several weaknesses or disadvantages of file processing systems but the major weakness is data redundancy and inconsistency. By data redundancy, I mean duplication of data. There are no better methods to validate insertion of duplicate data in file systems. Data redundancy can also increase the chance for errors.






7 0
3 years ago
Other questions:
  • Why do you think LinkedIn has become so popular?
    6·1 answer
  • What is the operating system?
    9·1 answer
  • How many homes can be warmed by one bugatti
    11·2 answers
  • How to eject a flash drive from chromebook?
    6·1 answer
  • Any program that allows the user to select an item from a menu should ________ the user's selection.
    7·1 answer
  • Please answer this correctly the underline drop down menu in the font group contains options to underline
    13·1 answer
  • If involved in a boating accident causing serious bodily injury or death while boating under the influence, the operator has com
    15·1 answer
  • Given a one dimensional array arr, what is the correct way ofgetting the number of elements in arr
    15·1 answer
  • What are invoices? A. Documents that convey a company's liabilities B. Documents that convey how much a company was earning and
    5·2 answers
  • 11111 Power 2 sovle ​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!