Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

12. What is the length of the line being drawn? G.drawline( 50, 20, 100, 350 );

ID: 3536241 • Letter: 1

Question

12. What is the length of the line being drawn?

G.drawline( 50, 20, 100, 350 );

15. What is the (x, y) coordinate of the lower right corner of the rectangle being drawn?

g.drawrect( 10, 20, 250, 350 );

Fill in the code

16. This code sets the current color to red.

// assume you have a graphics object named g

// your code goes here

17. This code draws the string “fill in the code†with the lower left corner of the first character (the F) being at the coordinate (100, 250)

// assume you have a graphics object named g

// assume you have a graphics object named g

Identifying errors in code

22. Where is the error in this code sequence?

// we are inside method paint

g.drawstring( ‘Find the bug’ , 100, 200 );

23. Where is the error in this code sequence?

// we are inside method paint

g.setColor( GREEN );

Explanation / Answer

12. What is the length of the line being drawn?

G.drawline( 50, 20, 100, 350 );

length = sqrt( (100-50)^2 + (350-20)^2) = sqrt( 50^2+ 330^2) = 333.7663853655727267

15. What is the (x, y) coordinate of the lower right corner of the rectangle being drawn?

g.drawrect( 10, 20, 250, 350 );

10+250 , 20-350

= 260, -330


Fill in the code

16. This code sets the current color to red.

// assume you have a graphics object named g

// your code goes here
g.setColor(Color.RED);

17. This code draws the string “fill in the code†with the lower left corner of the first character (the F) being at the coordinate (100, 250)

// assume you have a graphics object named g

g.drawString("Fill in the code",100,250);

Identifying errors in code

22. Where is the error in this code sequence?

// we are inside method paint

g.drawstring( ‘Find the bug’ , 100, 200 ); // it should be as follows

g.drawString( ‘Find the bug’ , 100, 200 );

23. Where is the error in this code sequence?

// we are inside method paint

g.setColor( GREEN ); // it should be as follows

g.setColor(Color.GREEN);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote