Write a java application that defines a circle and rectangle

Assignment Help JAVA Programming
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();

}

}

Reference no: EM131391080

Questions Cloud

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..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd