Results 1 to 12 of 12
Thread: code using array
- 12-17-2008, 06:59 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
code using array
hi
I have a project and I want some one to help me to do it with java language
Implement an array, to implement a game name ArrayHunt. Define the maximum size of the array. Insert elements into the array. Sort the elements ascending. Then search for any one item (specify in the code) and display the output whether the item is found or not
thanx
- 12-17-2008, 07:44 PM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
Post your code, all compiler/error messages you're getting, a complete description of how the actual behaviour differs from the desired behaviour, and ask an actual question.
FYI, we will not do this for you.
- 12-17-2008, 09:11 PM #3
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
i did the code but their are some mistake in it
i don't want you to solve it for me but to help me . i am a new student and i am learning java .
- 12-17-2008, 09:14 PM #4
if you did the code and saw mistakes post the code and error message you get so we know where to help you.
-
Most of us will be far better at helping you to solve your mistakes if we can actually see the mistakes. As posted above several times, do yourself a favor and post your code and the errors.i did the code but their are some mistake in it
i don't want you to solve it for me but to help me . i am a new student and i am learning java .
- 12-17-2008, 09:51 PM #6
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
this is my first part code.
1- array with size
2- insert elements to it
3- sort it in sanding order ( this part i did know how to do it)
-----------------------------------------------------
Java Code:import java.util.Scanner; class ArrayHunt { public static void main(String[] args) { int[] list=new int[5]; int i; System.out.println("Please Enter number of elements:"); Scanner input= new Scanner(System.in); for( i=0; i<list.length;i++) { list[i] = input.nextInt() ; } ArrayHunt objTest = new ArrayHunt(); objTest.methodTest(list); } public void methodTest(int[] value) { for(int i=0; i < value.length; i++) { System.out.println("the Number in ascending order: " + value[i]+"."); } } }
- 12-17-2008, 10:02 PM #7
What is "sanding order"?
Liberty has never come from the government.
Liberty has always come from the subjects of government.
The history of liberty is the history of resistance.
The history of liberty is a history of the limitation of governmental power, not the increase of it.
- 12-17-2008, 10:06 PM #8
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
sorry I mean in ascending order
- 12-17-2008, 10:19 PM #9
Array has a sort method that will auto sort in ascending order. If you required to do it manually think about how you would do this on paper. First you need to set a low value. then traverse through the array comparing the current value to that low value. If current value is less then low value then you replace low value with current value and repeat the process.
Fyi your going to need a second array or a swap method to switch numbers in your array.Liberty has never come from the government.
Liberty has always come from the subjects of government.
The history of liberty is the history of resistance.
The history of liberty is a history of the limitation of governmental power, not the increase of it.
- 12-18-2008, 05:47 AM #10
sorry
sorry,
i could not be able to understand properly.
- 12-18-2008, 06:45 AM #11
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
I don't see any attempt at sorting.
See the API docs for the class "Arrays" for a sort method, or, if you must do it manually, an easy way is to use a while loop and a for loop.
Run the for loop over the array, comparing the elements (one to the one that comes after it) swapping their positions when the first is larger, and keep doing it until no numbers change positions (the while loop).
At least try.
- 12-18-2008, 10:44 AM #12
Member
- Join Date
- Dec 2008
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Help with Code! Display Array of Strings and Integers - Sorted
By luvjoynt in forum New To JavaReplies: 7Last Post: 04-28-2008, 04:28 AM -
Array Reflection: Multi Array Reflection
By Java Tip in forum java.langReplies: 0Last Post: 04-23-2008, 08:08 PM -
please i need the code of comparing these two array lists.
By raj reddy in forum JavaServer Pages (JSP) and JSTLReplies: 5Last Post: 04-18-2008, 07:42 AM -
I need help fixing my code.. or non code?
By MrHuggykins in forum New To JavaReplies: 1Last Post: 03-19-2008, 10:12 PM -
Generating Code Automatically Using Custom code Template In Eclipse
By JavaForums in forum EclipseReplies: 1Last Post: 04-26-2007, 03:52 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks