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]
3 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]3 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
Anyone use zoom<br><br>code:- 2574030731<br>pass:- HELLO<br>Z●●M ​
r-ruslan [8.4K]

Answer:

ok be there in a sec

Explanation:

3 0
3 years ago
Read 2 more answers
I will give 100 points
UkoKoshka [18]

Answer:

sibling, fritend, or fellow styu346yhtwf vrrrrrrrgqreg t5

3 0
2 years ago
Someone pls help me do this and don't ask for brainliest or say random answers not related to this.
Marat540 [252]
I used to use pixlr all the time so i should know.
Ok so

1 is picker
2 is lasso select
3 is crop
4 is Liquefy
5 is clone
6 is dodge/burn
7 is Pen
8 is Eraser
9 is Gradient
10 is Text
11 is Zoom
12 is Switch Colors
13 is Marquee Select
14 is Wand select
15 is Cutout/Mask
16 is Heal
17 is Blur/Sharpen
18 is Sponge Color
19 is draw
20 is Fill
21 is I don’t know I have never seen that before
22 is Picker

So sorry if it took a while i did not know what the star was
3 0
3 years ago
Read 2 more answers
David is working in a database that organizes student exam grade information. He needs to find all students who have scored 100
kobusy [5.1K]

Answer:

David can apply filter to the data in order to show only records that meet the criteria.

Explanation:

  • Filter is a very helpful option that displays the records that you want to view, hiding rest of the unwanted records.
  • Sometimes you want to extract and view only the records that match a specific criteria instead of viewing all the records.
  • For example in the CUSTOMERS table which contains names, addresses, countries of customers. There are several customers from different countries but you only want to view the customers from Spain. So you can use filter feature to view all the customers from country Spain.
  • In MS Access you can apply filters using Sort & Filter group in the Home tab by selecting the desired column. In SQL, WHERE clause can be used along with SELECT to for filtering and extracting certain records. SELECT will select the records from the table and WHERE clause will specify the criteria to select the certain records.
7 0
3 years ago
One of the difficult things about working in game design is that while there are many different roles, most of them only match o
Papessa [141]

Answer:

it's false

Explanation:

they don't match to personalities

6 0
2 years ago
Other questions:
  • Rachel is on her way to an interview for the position of a project manager. She is trying to prepare for this interview by analy
    6·1 answer
  • You just received a message from the internet which was encrypted with asymmetric encryption. what do you need to do to read the
    12·1 answer
  • What are the five layers in the internet protocol stack? What are the principal responsibilities of each of these lay?
    9·1 answer
  • To exit Access, click the ____ button on the right side of the Access title bar.
    9·1 answer
  • Write 3 things that can't be done without technology. write your opinion?
    14·2 answers
  • Classify the various scenarios in a web development team that is creating a website for a client according to the priority level
    9·1 answer
  • 2 red and 2 overlapping balls in the center are surrounded by a green, fuzzy, circular cloud with a white line running through i
    15·2 answers
  • For a web application we associate a web server, for a mobile application we associate a mobile server. for a decentralized appl
    15·1 answer
  • What are some of the most common obstacles in video games?
    11·1 answer
  • Which of the following can be termed ‘application software’?​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!