Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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();

}

}

Java, Programming

  • Category:- Java
  • Reference No.:- M92200898
  • Price:- $25

Priced at Now at $25, Verified Solution

Have any Question?


Related Questions in Java

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As