May H.

asked • 07/19/17

Homework problem is in the description

Prepare a program that will perform the followings:
1) It will prepare a drawing area of 600 pixels by 600 pixels.
2) It will draw (not fill) a black rectangle with the following 4 corners:
(100, 100), (500, 100), (100, 500), and (500, 500).
3) It will ask the user to enter the following information on a circle:
the x-coordinate value of the center of the circle,
the y-coordinate value of the center of the circle, and
the radius of the circle.
4) It will draw(fill) the circle with the provided center and the radius.
But, it will use a different color for the circle depending on the
following conditions:
If the circle is completely enclosed within the rectangle, it will use
yellow. Else, it will use gray.

1 Expert Answer

By:

Andy C. answered • 07/19/17

Tutor
4.9 (27)

Math/Physics Tutor

Andy C.

You may need to put the input statements inside of a while loop
so as to allow valid input. For example, as written, negative numbers
can be input for the coordinates and the radius.
 
String inbuff;
centerX = centerY=radius = -1;
while (centerX<0)
{
 
    inbuff = JOptionPane.showInputDialog(" Please input the X coordinate of the center of the circle :>");
    centerX = Input.parseInt(inbuff);
}
//same validation loops for centerY and radius
 
Report

07/19/17

May H.

Java says that this is wrong, can you please help?
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Color;
import javax.swing.*;
Report

07/20/17

Andy C.

import java.awt.*;
Report

10/01/17

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.