Java Write code statements to create an array based on user values and determine if that array contains at least one unique value. Code Specifications All of your code can go in the main method. Ask the user how many numbers they want to enter. Create an int[] using this size. Use a loop to read in the user's values and store them in the array. Determine if there is at least one unique value in the array. Hint: use a nested loop! Output the result to the user. What I have so far: import java.util.Scanner; public class UniqueNumbers {     public static void main(String[] args) {         Scanner scan = new Scanner(System.in);         System.out.println("How many numbers do you want to enter?");         int numbers = Integer.parseInt(scan.nextLine());                  int[]values = new int[numbers];         for(int i = 0; i

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Java

Write code statements to create an array based on user values and determine if that array contains at least one unique value.

Code Specifications

All of your code can go in the main method.

  1. Ask the user how many numbers they want to enter.
  2. Create an int[] using this size.
  3. Use a loop to read in the user's values and store them in the array.
  4. Determine if there is at least one unique value in the array.
    • Hint: use a nested loop!
  5. Output the result to the user.

What I have so far:

import java.util.Scanner;

public class UniqueNumbers {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("How many numbers do you want to enter?");
        int numbers = Integer.parseInt(scan.nextLine());
        
        int[]values = new int[numbers];
        for(int i = 0; i<values.length; i++) {
            System.out.println("Enter a number:");
            values[i] = Integer.parseInt(scan.nextLine());
        }
        

    }

}

The picture is a table of test cases. I just need you to add the code that determines if there is a unique value

Number
of
Numbers
5
5
4
6
3
4
4
5
Values in
the Array
{1, 2, 3, 4,
5}
{1, 2, 2, 1,
3}
(3, 5, 1, 1)
{6, 8, 2, 8,
6,5}
{4, 4, 4]
{7,7,7,7}
{1, 2, 1, 2}
{4, 4, 3, 4,
3}
Contains a
Unique
Number?
yes
yes
yes
yes
no
no
no
no
Transcribed Image Text:Number of Numbers 5 5 4 6 3 4 4 5 Values in the Array {1, 2, 3, 4, 5} {1, 2, 2, 1, 3} (3, 5, 1, 1) {6, 8, 2, 8, 6,5} {4, 4, 4] {7,7,7,7} {1, 2, 1, 2} {4, 4, 3, 4, 3} Contains a Unique Number? yes yes yes yes no no no no
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY