| | |
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: 327
Reputation:
Solved Threads: 50
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 |
-xlint actionlistener add android applet application array automation bank bi binary blackberry block bluetooth character class client code compile compiler component consumer database desktop developmenthelp eclipse equation error event fractal ftp functiontesting game gameprogramming givemetehcodez graphics gui health html hyper idea image infinite int j2me j2seprojects java javac javaee javame javaprojects jetbrains jni jpanel jtable julia learningresources lego linked linux mac main method mobile myregfun netbeans notdisplaying number online pearl printf problem program qt researchinmotion rotatetext rsa scanner screen server set singleton sms sort spamblocker sql string swing system textfields thread threads time title tree tutorial-sample update variablebinding windows xor





