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
Nataliya [291]
2 years ago
11

Write a program FindDuplicate.java that reads n integer arguments from the command line into an integer array of length n, where

each value is between is 1 and n, and displays true if there are any duplicate values, false otherwise.
Computers and Technology
1 answer:
kozerog [31]2 years ago
7 0

Answer:

  1. public class FindDuplicate{
  2.    public static void main(String[] args) {
  3.        Scanner input = new Scanner(System.in);
  4.        int n = 5;
  5.        int arr[] = new int[n];
  6.        for(int i=0; i < arr.length; i++){
  7.            int inputNum = input.nextInt();
  8.            if(inputNum >=1 && inputNum <=n) {
  9.                arr[i] = inputNum;
  10.            }
  11.        }
  12.        for(int j =0; j < arr.length; j++){
  13.            for(int k = 0; k < arr.length; k++){
  14.                if(j == k){
  15.                    continue;
  16.                }else{
  17.                    if(arr[j] == arr[k]){
  18.                        System.out.println("True");
  19.                        return;
  20.                    }
  21.                }
  22.            }
  23.        }
  24.        System.out.println("False");
  25.    }
  26. }

Explanation:

Firstly, create a Scanner object to get user input (Line 4).

Next, create an array with n-size (Line 7) and then create a for-loop to get user repeatedly enter an integer and assign the input value to the array (Line 9 - 14).

Next, create a double layer for-loop to check the each element in the array against the other elements to see if there is any duplication detected and display "True" (Line 21 - 22). If duplication is found the program will display True and terminate the whole program using return (Line 23). The condition set in Line 18 is to ensure the comparison is not between the same element.

If all the elements in the array are unique the if block (Line 21 - 23) won't run and it will proceed to Line 28 to display message "False".

You might be interested in
2. As you have learned, ironically, a large part of sound production involves visual perception. How easy or difficult did you f
Alex787 [66]

Answer: it is very easy to work with programs such as audacity, they are real game changers. Also, they are very helpful for editing and recording audio. They could make audacity’s auto tune more beginner friendly

3 0
2 years ago
A state government is attempting to reduce the digital divide. Which of the following activities has the greatest potential to c
Sveta_85 [38]

Answer:

The correct answer is

Working with technology companies to offer computing devices at discounted prices to individuals with reduced incomes

Explanation:

As per the question, state government is trying to reduce the digital divide which primarily exists because low income people do not have access to the digital devices. Hence, any step taken to help the low income people to get the digital device will be the best strategy of government to reduce the digital divide.

Thus, the correct answer is Working with technology companies to offer computing devices at discounted prices to individuals with reduced incomes

7 0
3 years ago
There are information that are in the web view source that may not appear on the web page such as meta name. In addition there c
SCORPION-xisa [38]

Answer:

True on a web page such meta name will not appear in web view source and irrelevant information will be displayed.

Explanation:

Basically web page source is compiled version of HTML script so the end-user he or she tries to view pages system will show only in HTML.

so meta name information and active object information will not be displayed while viewing the web source code instead of that the irrelevant informant ions will be displayed and end-user cannot under anything out of the web source code.

Moreover, even the client side validation script also will not be displayed.

Only HTML will be displayed  

3 0
3 years ago
The__________is an HTML tag that provides information on the keywords that represent the contents of a Web page.
enyata [817]

Answer:

Meta tag

Explanation:

5 0
3 years ago
To save a document with a new name, click _______ in the navigation bar and enter a new filename.
cricket20 [7]
Click the save as button
3 0
3 years ago
Other questions:
  • Is a type of bullying that takes place when a person intentionally posts negative information about another that is not true
    8·1 answer
  • The local emergency manager has the responsibility for coordinating emergency management programs and activities. A local emerge
    7·1 answer
  • Jennifer's company currently uses Windows Active Directory to provide centralized authentication, authorization, and accounting
    14·1 answer
  • The _________ in Java is passed by value but ______ is passedby reference.
    5·1 answer
  • Suppose L is a LIST and p, q, and r are positions. As a function of n, the length of list L, determine how many times the functi
    8·1 answer
  • . How to insert Section Break in Microsoft word 2016 ?
    14·1 answer
  • When adopting the use of social media in emergency management, it is important to have
    10·1 answer
  • Giving brainliest if you answer question.
    8·1 answer
  • When locating and correcting accessibility issues for a document, you would click what first?
    11·1 answer
  • Passing an argument by ___ means that only a copy of the arguments value is passed into the parameter variable and not the addrt
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!