Hey guys, ive been working on this applet for awhile and I can't get it.
I need to an applet that reads five numbers (each between 1 and 30). For each number read, it should draw a line containing that number of adjacent asterisks. For example, if input the number seven, it should print *******.
I have this but im not sure what kind of control structure to use that will check to see if the number is in 1-30 parameter and to loop to print out the "*"'s.
Code:import javax.swing.*; import java.awt.Graphics; public class L5a1 extends JApplet{ int num1, a=1; public void init() { String one, one = JOptionPane.showInputDialog ( "Enter first number, 1-30 please:" ); //converts string to integer num1 = Integer.parseInt(one); num1=a; num1=1; } public void paint ( Graphics g ) { for (num1=1; num1 > a; num1++) { g.drawString ( "*", num1, 10); } } }
Theres only 1 structure in for simplicty. Im not sure what to use for the the check on the 1-30 either. I need some real help on this one, i know what i want to do but don't know how to do it...
thanks
JW


Reply With Quote


Bookmarks