• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Java Help...

jai6638

Golden Member
Hey.. am in a Intro to Programming class and the following is my assignment:

1. Using the Turtle Graphics Java Package create a smile face or pumpkin face.

2. This face must have the following:
a. The head must be round. See the code below to get a circle.
b. You must use the 6 Turtle Graphics Pen Messages that can be found on the handout on my website.
c. The eyes, nose and mouth must be at least 3 sides and implemented by a loop. (repetition structure)
d. Half circle for mouth
(Hint: the for loop that only loops 3 times for each eye)
e. Draw a flow chart of your program using the correct symbols and logic.
f. Submit a copy of your source code and flowchart.
______________________________________________________________


THe following is my source code

import TurtleGraphics.*;
class face
{
public static void main(String[] args)
{
// create a pen object
SketchPadWindow pad = new SketchPadWindow(600, 600);
Pen pen = new StandardPen(pad);

// declare a variable for drawing circle
int i;

// Draw Circle for face
pen.home();
pen.setDirection(90);
pen.down();
for(i=0; i<=120; i++)
{
double side = 2.0*3.14*50.0/120.0;
pen.move(side);
pen.turn(3);
}

//draw second eye ( eye on the right )

pen.up();
pen.home();
pen.turn(90);
pen.up();
pen.move(16);
pen.down();
pen.move(20);
pen.turn(-140);
pen.move(15);
pen.turn(-90);
pen.move(12);

//draw first eye ( eye on the left )

pen.turn(-128);
pen.up();
pen.move(40);
pen.down();
pen.move(16);
pen.turn(-140);
pen.move(16);
pen.turn(-90);

The problem is that i need to loop the eyes and nose ( as requested by my teacher in point C ) so as to prevent the use of Pen commands again and again... how do i do this?


thanks much ..
 
I'm going to go out on a limb and guess <a target=_blank class=ftalternatingbarlinklarge href="http://PROGRAMMING[/b] AND GAMES]http://forums.anandtech.com/categories.aspx?catid=33&flcache=8468220&ente
cat=y">SOFTWARE - APPS, [b</a>... but I could be wrong.
 
^^^ That got messed up.

I'm going to go out on a limb and guess <a target=_blank class=ftalternatingbarlinklarge href="http://forums.anandtech.com/categories.aspx?catid=33&flcache=8468220&ente
cat=y">SOFTWARE - APPS, SOFTWARE AND GAMES</a>... but I could be wrong.
 
Originally posted by: jai6638
awrite... i posted it in the Software forum.... sorry for posting it in the wrong forum.......
It's not a big deal, it's just that so many people post things here that don't belong here just because there are more people and they'll get a response faster. If we don't jump on them and give them no worthwhile advice, we'd get hammered by this stuff.
 
Back
Top