| | |
how to sort the output in descending
![]() |
•
•
Join Date: Nov 2008
Posts: 8
Reputation:
Solved Threads: 0
alright..
i have a problem on how to sort the output
my code is here:
the output is simply:
all i want to do is to print first 19,18 and so on.
what should i modify?
i have a problem on how to sort the output
my code is here:
Java Syntax (Toggle Plain Text)
public class Num7 { public static void main(String[]args) { char[] ch; ch=new char[20]; int i; for(i=0;i<ch.length;i++) System.out.print(i); } }
Java Syntax (Toggle Plain Text)
012345678910111213141516171819
what should i modify?
I feel you are posting your class assignments here one by one, while we do not have any problem outright with that there should be some effort from your side that comes across from your query/ problem. We haven't seen any such effort as yet from you on this post.
Read this before posting such queries here.
Read this before posting such queries here.
•
•
Join Date: Nov 2008
Posts: 8
Reputation:
Solved Threads: 0
ok,
this is my modify code:
it display the values i entered on the array backward,
and that's what i want,
the problem is the value of z,
z is always 0;
i cant figure out whats the problem,
can you help?
this is my modify code:
Java Syntax (Toggle Plain Text)
public class Num7 { public static void main(String[]args) { char[] ch={'1','2','3','4','5','6','7','8','9'}; int x,y,z; for(x=ch.length;x>0;x--) { System.out.print(x); } System.out.println(); for(y=ch.length;y>0;y--) { System.out.print(y); } z=x*y; System.out.println("\nThe sum is: "+z); } }
and that's what i want,
the problem is the value of z,
z is always 0;
i cant figure out whats the problem,
can you help?
Last edited by beginner21; Dec 1st, 2008 at 3:17 am. Reason: code tags
•
•
Join Date: Nov 2008
Posts: 332
Reputation:
Solved Threads: 53
In Your code
When loops finished x=0 and y=0.Multipy them result is 0.
You not using
Analyse this:
quuba
int x,y; are indexes of loop - for.When loops finished x=0 and y=0.Multipy them result is 0.
You not using
char[] ch={'1','2','3','4','5','6','7','8','9'}; table. More proper is declare table as int.Analyse this:
java Syntax (Toggle Plain Text)
public static void main(String[] args) { int[] table = {9,8,7,6,5,4,3,2,1,0}; for (int x = table.length-1; x >= 0; x--) { System.out.print("x="); System.out.print(x); System.out.print(" "); System.out.print("table[x]="); System.out.print(table[x]); System.out.println(); } System.out.println(); }
quuba
![]() |
Similar Threads
- subscript require array or pointer (C++)
- data structure >> sort (C++)
- Sort in descending order.... (C++)
- 2nd try (C++)
- HELP! (C++)
- I can't sort out Insertion Sort! (C)
- help with parrallel arrays (C++)
- Need Help Revising Array program: Visual C++ (C++)
Other Threads in the Java Forum
- Previous Thread: Audio Analyzer
- Next Thread: Hi/Lo code problems
| Thread Tools | Search this Thread |
actuate add android api applet application applications array arrays automation balls bank binary bluetooth business chat class clear client code codesnippet collections component database defaultmethod development dice digit dragging ebook eclipse equation error event formatingtextintooltipjava fractal functiontesting game givemetehcodez graphics gui health hql html hyper ide idea image infinite int integer invokingapacheantprogrammatically j2me java javame javaprojects jni jpanel julia linux list main map method methods mobile myregfun mysql netbeans nonstatic openjavafx parameter pearl php problem program project recursion repositories scanner scrollbar server set sms sort sorting spamblocker sql sqlserver state storm string sun superclass swing swt thread threads tree windows





