Jump to content

Duplicates in array removal using method

- - - - -

  • Please log in to reply
4 replies to this topic

#1
Dnectrum

Dnectrum

    Newbie

  • Members
  • Pip
  • 9 posts
I am trying to enter 10 numbers, and with those 10 numbers removal duplicates and only print them. I have no clue where to start with a method to actually calculate whether its a duplicate or not.

Any help would be appreciated, this is for a 1st year Java programming class so we haven't learned any serious techniques, mainly just a foundation of sorts

Any ideas?

import java.util.*;

import javax.swing.*;


class lab8

{

	public static void main(String[] args) 

	{

		Scanner input = new Scanner(System.in);

		int[] orig_array = new int[10];


		System.out.print("Enter 10 Numbers ");

    

		int k;

		

		for(k=0;k<orig_array.length;k++)

		{

			orig_array[k]= input.nextInt();

		}


	}


	public static int[] eliminateDuplicates(int[] numbers)

	{

		


	}

}


#2
fread

fread

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 787 posts
Try to work out the solution with a pen and paper first using the idea of array subscripts. Then try to formulate an algorithm.
Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:

#3
Dnectrum

Dnectrum

    Newbie

  • Members
  • Pip
  • 9 posts
I'll give it a try, I have like 4 labs to do to pass this class by wednesday. I thought I had a good foothold on arrays but these next 4 labs have got me going crazy. I am all for working it out, just wish my teacher would email me faster with some feedback.

My idea is to be able to compare the orig_array that is storing my entries against "something" but I can't seem to get it write on paper either.

#4
fread

fread

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 787 posts
You may find this Thread very useful: http://forum.codecal...s-1d-array.html
Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:

#5
Dnectrum

Dnectrum

    Newbie

  • Members
  • Pip
  • 9 posts
Okay, I read the post before when I had used the search function. I think I am just getting hung up on all the subscripts and variables in the examples shown and I just can't comprehend them. I'm going to be working on it all day tomorrow after class so hopefully something with arise. If you have anymore input feel free, Ill be checking back.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users