+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    2

    i need help with this java code [im a beginner]... PLEASE REPLY ASAP

     
    this is my source code for a lab im doing for my school..

    they array is showed after i enter the 10 numbers...

    what i need to do is when a number in the array is repeated... to disclam it and move on to the next number... so it would look something like this

    what i have....
    The array is 1 4 3 4 2 5 6 8 9 7 [the 4 repeats]

    what i want it to do is
    The array is 1 4 3 2 5 6 8 9 7 [ disclaims the repeated number]

    need a linearSearch method!
    and gets rid of the repeated number

    any code ideas?




    import java.util.Scanner;

    public class Exercise {
    public static void main (String[] args){

    final int NUMBER_OF_ELEMENTS = 10;
    int [] numbers = new int[NUMBER_OF_ELEMENTS];

    Scanner input = new Scanner(System.in);

    for (int i = 0; i < numbers.length; i++) {

    System.out.print("Enter a Number: ");

    numbers = input.nextInt();
    }

    String output = "\nThe Array is ";
    for (int i = 0; i < numbers.length; i++){
    output += numbers + " "
    }
    }

  2. #2
    Junior Member
    Join Date
    Oct 2010
    Posts
    2
    if you need more info, or need more clarification please feel free to ask... i really need help with this since it is due on wednesday!

  3. #3
    Caveat Emptor Rootstonian's Avatar
    Join Date
    Mar 2005
    Location
    Out of my mind
    Posts
    3,326
    Well, this is waaay late, but did you need to REMOVE the duplicate or just not DISPLAY it; 2 different animals there.

    You probably solved it with nested for loops....for each item in array, then search each item in array for same number...set a boolean ("not_duplicate") to false if not found....then if(not_duplicate,) print

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Beginner java code script not loading images
    By cov010 in forum Webmastering and Programming
    Replies: 0
    Last Post: October 4th, 2009, 01:15 PM
  2. Beginner, javascript code help!
    By snikker74 in forum Webmastering and Programming
    Replies: 4
    Last Post: April 4th, 2008, 11:08 AM
  3. Quick Reply Code...
    By CodemanCJQ in forum Webmastering and Programming
    Replies: 3
    Last Post: March 17th, 2004, 08:45 PM

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Recommended Sites: ResellerRatings Store Reviews