-
October 21st, 2010, 05:40 PM #1Junior 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 + " "
}
}
-
October 22nd, 2010, 12:38 PM #2Junior 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!
-
November 29th, 2010, 04:22 PM #3
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
-
Beginner java code script not loading images
By cov010 in forum Webmastering and ProgrammingReplies: 0Last Post: October 4th, 2009, 01:15 PM -
Beginner, javascript code help!
By snikker74 in forum Webmastering and ProgrammingReplies: 4Last Post: April 4th, 2008, 11:08 AM -
Quick Reply Code...
By CodemanCJQ in forum Webmastering and ProgrammingReplies: 3Last Post: March 17th, 2004, 08:45 PM



LinkBack URL
About LinkBacks



Reply With Quote

Agent Luke Hobbs enlists Dominic Toretto and his team to bring down former Special Ops soldier Owen Shaw, leader of a unit specializing in vehicular warfare. Watch Fast & Furious 6 Online Free...
Watch Fast & Furious 6 Online Free...