Reference no: EM131391080
Java Programming
Write a java application that defines a Circle and a Rectangle and prints the area of each. Make use of encapsulation to defined class attributes and methods.
A circle has three attributes: center Point, radius, and area. Use a proper constructor to initialize Circle object. To initialize a circle, you will need a center point and a radius. Then, you can use the radius to calculate the area of a circle. The area of a circle is calculated using the following equation (PI = 3.14):
Area = PI * radius * radius
A Rectangle consists of four Points which are the upper left, upper right, lower left, and lower right corner points, length, height, and area. To initialize a rectangle, you will need the coordinates of all four corner points from which you can calculate the length, the height, and the area of a rectangle. The area of a rectangle is calculated using the following equation (Note that length is the distance between the upper left and upper right corner points and height is the distance between the upper left and lower left corner points):
Area = length * height
The Point class defines the X and Y coordinates of a point. The distance between two points is calculated using the following equation:
Distance = sqrt((x2 - x1)^2 + (y2 - y1)^2)
For each class define displayInfo( ) method that would output information about an object. You can use the following main method to test your application. A sample output of the application is also shown below.
public class ShapeApp {
public static void main(String[] args) {
Point upperLeft = new Point(1, 5);
Point lowerLeft = new Point(1, 1);
Point upperRight = new Point(5, 5);
Point lowerRight = new Point(5, 1);
Rectangle r1 = new Rectangle(upperLeft, upperRight, lowerLeft,lowerRight);
r1.display();
Point center = new Point(10,10);
int radius = 4;
Circle c1 = new Circle(center, radius);
c1.display();
}
}
Who is entitled to the insurance proceeds
: Leonard Wolfe was killed in an automobile accident while driving his Toyota Camry.- Who is entitled to the insurance proceeds?
|
How does the simulation demonstrate these
: What are some measures a company may take to reasonably accommodate people with disabilities, or those with a known drug abuse problem, and how does the simulation demonstrate these?Should factors like personality, attitude toward work, and futur..
|
Assignments to research current findings relative
: Explore beyond your reading assignments to research current findings relative to the pathogen and their impact on current medical practice. The outline should contain the following on the selected pathogen:
|
Does the information media have social responsibility
: Does the information media have social responsibility? If yes, in what ways? If not, why not?What is the role of the information and news media in the shaping of political opinions?How have electronic media and their convergence transformed journalis..
|
Write a java application that defines a circle and rectangle
: Write a java application that defines a Circle and a Rectangle and prints the area of each. Make use of encapsulation to defined class attributes and methods.
|
What interest does henry acquire in the oil business
: What interest, if any, does Mary acquire in Blackacre?- What interest, if any, does Henry acquire in the oil business?
|
Discuss the validity of each claim
: Arnold died some time later, and the deed and will were found in his safe. Burton, Connie, and Ernest claim the farm, and Donna claims dower. Discuss the validity of each claim.
|
How it could be used to enhance the companys strengths
: Then, write a paper suggesting how IT could be used to enhance the company's strengths, lessen the company's weaknesses, take advantage of the company's opportunities, and / or mitigate the company's threats.
|
Discuss the thoughts about hr functions in todays world
: In Chapter 1 we talk about the role HR plays within today's organizations. It's logical is it not? Today, the most valuable asset a company can have is its employees! Years ago while pursuing our MBAs, we took courses in Inventory Management, Prod..
|