subject

Define an interface named Shape with a single method named area that calculates the area of the geometric shape: public double area();

Next, define a class named Circle that implements Shape. The Circle class should have an instance variable for the radius, a constructor that sets the radius, an accessor and a mutator method for the radius, and an implementation of the area method.
Define another class named Rectangle that implements Shape. The Rectangle class should have instance variables for the height and the width, a constructor that sets the height and the width, accessor/mutator methods for the height and the width, and an implementation of the area method.
The following test code should then output the area of the Circle and Rectangle objects:

public static void main (String[] args) {

Circle c = new Circle(4); //Radius=4
Rectangle r = new Rectangle(4, 3); // Height = 4, Width = 3

ShowArea(c);
ShowArea(r);

}

public static void ShowArea(Shape s) {

double area = s. area();

System. out. println("The area of the shape is " + area);

}

Defining an Inner Class

Rewrite the given classes Employee, HourlyEmployee, so that the class Date is an inner class of the class Employee and an inherited class of the class HourlyEmployee.
Write a program to instantiate at least two objects each of type Employee and HourlyEmployee. Display the hire dates for each employee and then modify and display the hire dates for each of the employees.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:30
Today is the anniversary of me being on yet, i don't need it anymore! here's a picture of my dog wearing a bowtie! my question is, how do i delete my account?
Answers: 1
question
Computers and Technology, 23.06.2019 09:10
(328 inc. 448 ind. 480 in25. john has a collection of toy cars. he has 2 red cars, 4 blue cars, 4 black cars, and 6 yellowcars. what is the ratio of red cars to yellow cars? a. 1: 2b. 1: 3c. 1: 626. the net of a right triangular prism is shown below.
Answers: 2
question
Computers and Technology, 23.06.2019 20:30
What are some settings you can control when formatting columns?
Answers: 1
question
Computers and Technology, 23.06.2019 21:20
For positive constants a and b, the force between two atoms in a molecule is given f(r) = −a r2 + b r3 , where r > 0 is the distance between the atoms. note: a and b are upper case letters. (a) find f '(r) = (b) find the critical point for f(r). r = (c) find f ''(r) = (d) find the value of r so that f ''(r) = 0.
Answers: 1
You know the right answer?
Define an interface named Shape with a single method named area that calculates the area of the geom...
Questions
question
Mathematics, 04.10.2021 22:10
question
Physics, 04.10.2021 22:10
Questions on the website: 13722361