I have an external file with some random numbers but some are duplicates. I need to write a program that reads the numbers and prints out all the numbers that there are. Then I need to write a program that then prints all the numbers without their duplicate this is what i have so far. I apologize if my formatting is not right on this question. I am new to Stack overflow.
import java.io.*;
import java.util.Scanner;
public class main
{
public static void main (String [] args)throws Exception
{
Scanner sf = new Scanner(new FileInputStream("prog415h.dat"));
int[] number = new int[100];
int count = 0;
Runner runner = new Runner();
while(sf.hasNextLine())
{
number[count] = sf.nextInt();
System.out.print("The orginal set of numbers are: " + number[count] + " ");
count++;
}
runner.Repeat();
}
}
public class Runner
{
public static int[] numbers;
public static void setNumbers(int[] numbers)
{
Runner.numbers = numbers;
}
public static void Repeat()
{
for (int i = 0; i < 30; i++)
{
int x = numbers[i];
boolean good = true; //any duplicates found?
for (int j = 0; j < 30; j++)
{
if (i != j) //dont compare it to itself
{
if (x == numbers[j]) // duplicate
{
good = false;
System.out.print("");
}
}
}
}
}
}