# Thread: please help me.....please...

1. Member
Join Date
Jul 2009
Posts
17
Rep Power
0

## please help me.....please...

i got an assignment to do..
the assignment is:
write a program about sorting a negative to positive number in easy word from small to big number..
the original number given is:23 45 -234 -456 -2 -4 333 56 35
the sorted number is:-456 -234 -4 -2 23 35 45 56 333
please help me to write the syntax or coding using for loop and array condition..
please help me...
your help is very2 necessary for me to completing the task..
thank you..
reply me as soon as possible..
Last edited by amalina; 07-21-2009 at 10:24 AM. Reason: left some words

2. Senior Member
Join Date
Dec 2008
Location
Kolkata
Posts
283
Rep Power
9
I think you should try to do it yourself first. If you face problem we are always here to help you.

3. Member
Join Date
Jul 2009
Posts
17
Rep Power
0

## please again

i have tried to do by myself..
now there no much time left..
i have no idea what to do anymore..
its have come to the end of my critical thinking..
i cannot find any solution anymore..
could somebody help me out of this problem..
plz..
i need ur help..
a.s.a.p
:(

4. Senior Member
Join Date
Dec 2008
Location
Kolkata
Posts
283
Rep Power
9
Java Code:
```int nums[]={23,45,-234,-456,-2,-4,333,56,35};
for (int i = 0; i < nums.length - 1; i++){
for (int j = i + 1; j < nums.length; j++){
if (nums[i] > nums[j]){
int temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
}
}
}```

5. Member
Join Date
Jul 2009
Posts
17
Rep Power
0

## i like to have in detail syntax..

the output have to be like this:
original number:23 45 -234 -456 -2 -4 333 56 35
sorted number:-456 -234 -4 -2 23 35 45 56 333
and the problem with your code is..
i didn't see any output..
but its stated build successful..
with none of the output i wanna see..
please help me once again..
i really appreciate ur help...

6. Senior Member
Join Date
Dec 2008
Location
Kolkata
Posts
283
Rep Power
9
Java Code:
```int nums[]={23,45,-234,-456,-2,-4,333,56,35};
for (int i = 0; i < nums.length - 1; i++){
for (int j = i + 1; j < nums.length; j++){
if (nums[i] > nums[j]){
int temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
}
}
}
//you just need to print the array after sorting
for (int i = 0; i < nums.length; i++){
System.out.print(nums[x]+" ");
}```

7. Member
Join Date
Jul 2009
Posts
17
Rep Power
0

## i didnt not understand it well..

i said i want the output like i show u before..
it must have display the original and the sorted number...
its mean there is two line of output...
is ur code is readable by netbeans software...
i am so sorry..
that is y i ask the expert to solve my prob about this...
very2 sorry..

8. Senior Member
Join Date
Dec 2008
Location
Kolkata
Posts
283
Rep Power
9
Java Code:
```public static void main(String[] arg){
int nums[]={23,45,-234,-456,-2,-4,333,56,35};

int unsortedNums[]=new int[nums.length];

//store the original numbers in the array called unsortedNums for displaying later
for(int x=0;x<nums.length;x++){
unsortedNums[x]=nums[x];
}

//sort the nums array
for (int i = 0; i < nums.length - 1; i++){
for (int j = i + 1; j < nums.length; j++){
if (nums[i] > nums[j]){
int temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
}
}
}
//display the original array i.e. array called unsortedNums
System.out.print("Original Numbers:");
for(int x=0;x<unsortedNums.length;x++){
System.out.print(unsortedNums[x]+" ");
}

//display the sorted array i.e. array called nums
System.out.print("\nSorted Numbers:");
for(int x=0;x<nums.length;x++){
System.out.print(nums[x]+" ");
}

//just to print a blank line
System.out.println("");
}```

9. Member
Join Date
Jul 2009
Posts
17
Rep Power
0

## tq damn much...

without your help..
i cannot solve the problem...
thank you...
very2..
much...
i hope you can help me with the..
upcoming problem..
about java...
thank you....

10. hmmm... nice spoonfeeding session going on...

11. Moderator
Join Date
Apr 2009
Posts
13,132
Rep Power
23
Oh joy. Someone else I'll have to clean up after in a few years time.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•