| | |
how to sort the output in descending
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
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: 54
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 |
Tag cloud for Java
-xlint 2dgraphics android api apple applet application applications arguments array arrays automation bank binary bluetooth chat class classes client code collision component database db development draw eclipse eclipsedevelopment error event exception file fractal game givemetehcodez graphics gui helpwithhomework homework html ide image input integer integration j2me jarfile java javadesktopapplications javafx javaprojects jmf jni jpanel julia learningresources linux list loop map method methods mobile netbeans newbie number object oracle print problem program programming project projectideas recursion researchinmotion scanner screen server service set size sms socket sort sorting sql sqlserver state string swing swt tcp test text-file threads time tree web windows





