More info on simple program
Thanks for your interest. I will try to elaborate further on the specific problem I have encountered.
My problem is in geting more than one asterisk per input number to show in the applet window, using the command
The applet runs in Kawa 5 and ie6 but only prints one asterisk per integer i.e. if I enter 6 the applet shows
When I write the program as an application the program works using the
The program although inelegant should work, I think the problem is with using g.drawString to output the asterisks ( or maybe not ).
A few thoughts on your problem.
First, it seems that your drawString() method is causing the non appearance of the astrisks. You've written:
g.drawString("*" + num5,25, 25);
which means the asterisk and num5 will be drawn however many times the for() loop specifies IN EXACTLY THE SAME POSITION. So, although it LOOKS like it's only drawn once, it is ACTUALLY drawn the number of times in the for() loop...just in the same place. Like a typewriter that has got stuck, pressing the "q" key 10 times will print "q" ten times in the same place. To remedy the sitiuation change the 'x' coordinate to a variable which changes due to the loop. For example:
Notice I've left out the num5...or it'll get printed however many times the for() loop specifies AS WELL. You'll need to draw the number string first, using relevant coordinates: leaving enough room for it AND the asterisks, and then draw the asterisks.
I've also noticed the following:
for(int i5=1; i5<= num5; i5++)
if (i5 <= num5)
the second piece of code seems to be unnecessary. The for() loop will only perform while i5 is 1 to 5 inclusive. Therefore, anything INSIDE that loop will only be performed while i5 is 1 to 5 inclusive.
Finally, are you wanting the user to enter 5 separate numbers BEFORE all the maths and asterisks things are done? It looks like there is only one opportunity for input at present. To enable 5 numbers you'll need to use another loop ( eg. for() ) and an array to store them in.
Hope this is of some use to you.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL