Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//Trying to make Java program to put unique numbers in an array to different array and print. //Numbers entered in the file are sorted but

//Trying to make Java program to put unique numbers in an array to different array and print.

//Numbers entered in the file are sorted but have duplicates

public static void main(String[] args)

{ StdOut.print("File to read in: "); String filename = StdIn.readLine();

In infile = new In(filename); int[] numbers = infile.readAllInts();

int n = numUniquey.length; int [] numUniquey= add_element(n, numUniquey, ele); StdOut.println("These are the unique numbers " + numUniquey);

}

public static int[] add_element(int n,int[] a, int ele) { int lengthus= a.length; int numUnique= 0; int [] numUniquey= new int[lengthus-1]; for (int i=0; i < (lengthus); i++) { while( (i < lengthus -1) && a[i] == a[i+1]) { i++;

} numUnique++; numUniquey= add_element((lengthus-1), numUniquey, a[i]); } return numUniquey;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

Convert \(38.7 \%\) to decimal form.

Answered: 1 week ago

Question

3.2 Discuss the strategic importance of technology in HRM.

Answered: 1 week ago

Question

Question Who can establish a Keogh retirement plan?

Answered: 1 week ago