Welcome to Dream.In.Code
Become a Java Expert!

Join 149,499 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,389 people online right now. Registration is fast and FREE... Join Now!




need help with draws 5 random circles

 
Reply to this topicStart new topic

need help with draws 5 random circles, random radius (between 20 and 150) random locations

sailboat
20 Mar, 2007 - 02:48 PM
Post #1

New D.I.C Head
*

Joined: 20 Mar, 2007
Posts: 1


My Contributions
/* draws 5 circles with random radius (between 20 and 150) random locations , ensure that all circle appears in the visiable area of the applet*/

import java.util.Random;
import javax.swing.JApplet;
import java.awt.*;

public class Project1PartII extends JApplet
{
public void paint (Graphics page)
{
final int PAGE_WIDTH = 400;
final int PAGE_HEIGHT = 300;

int x, y, r, count;

page.drawString ("Si Bo Zhu", 180, 150);

for (count = 0; count < 5; count++)
{
x = (int)(Math.random()*400);
y = (int)(Math.random()*300);
r = (int)(Math.random()*150);
page.drawOval (x, y, 2*r, 2*r);
}
}
}

This post has been edited by sailboat: 20 Mar, 2007 - 02:53 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 06:22PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month