11-11-2004, 08:22 PM | #1 | |
The Obfuscated One
|
programmers unite!
I am having a problem with this java program
/** this program * makes the astrixes * go down the side! */ import javax.swing.JOptionPane; public class Graph { public static void main( String args[] ) { int c; String s1; int x; s1 = JOptionPane.showInputDialog( "Enter an integer:" ); c = Integer.parseInt( s1 ); do { System.out.println(x * "*"); /* I want this to have "x" astrixes, but it yells at me until I take the x* out */ c=c-1; x=x+1; } while ( c>0 ); } }
__________________
Quote:
Last edited by Bailey; 11-11-2004 at 10:11 PM. |
|
11-11-2004, 08:29 PM | #2 | |
NOT on Probation!
|
Instead of that SOPln line, make it as follows.
for (int i=x, i>0, i--) {SOP("*"); SOPln();} //Make sure its inside the do statement, just cut and paste. It should work. Dr Edit adds: Whoops, heheh misread your program. Ends up the number of stars increase until it stops! Ain't that silly? So yea, I'm not sure how to fix this, good luck with your programation.
__________________
44% of all percentages are made up on the spot. Quote:
^Referring to tidky.Ahh... How I love our mods. Did you know that BIG text attracts attention? Last edited by AndyBloodredMage; 11-11-2004 at 08:39 PM. |
|
11-11-2004, 08:36 PM | #3 | |
The Obfuscated One
|
I ended up going with this for a while
/** this program * makes the astrixes * go down the side! */ import javax.swing.JOptionPane; public class Graph { public static void main( String args[] ) { int c; String s1; int x; x=1; s1 = JOptionPane.showInputDialog( "Enter an integer:" ); c = Integer.parseInt( s1 ); do { System.out.println(x+"*"); c=c-1; x=x+1; } while ( c>0 ); } } but then I fixed it: /** this program * makes the astrixes * go down the side! */ import javax.swing.JOptionPane; public class Graph { public static void main( String args[] ) { int c; String s1; int x; int y; x=0; y=0; s1 = JOptionPane.showInputDialog( "Enter an integer:" ); c = Integer.parseInt( s1 ); do { while (y>0){ System.out.print("*"); y=y-1; } System.out.println("*"); c=c-1; x=x+1; y=x; } while ( c>0 ); } }
__________________
Quote:
Last edited by Bailey; 11-12-2004 at 04:36 PM. |
|
11-12-2004, 04:35 PM | #4 |
Oh hi! :D
|
Newb, that's great. Only one thing wrong with it. You double posted. Why don't you use the edit button and make it one long post?
|
11-12-2004, 04:37 PM | #5 | |
The Obfuscated One
|
oops, my bad. it's fixed now
__________________
Quote:
|
|
|
|