Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1: Create a new class named Flower with the following fields and methods: Fields: - color that stores the color of the flower (pink,

Question 1:

Create a new class named Flower with the following fields and methods:

Fields:

- color that stores the color of the flower (pink, yellow, red ).

- two double variables d1 and d2 indicating the diagonals of the flower's petal. These values should be positive.

Methods:

1. readFlower() that reads the values of the flower fields from the keyboard.

2. flowerArea() is a static method that computes the area of the flower's petal using the following equation: area = d1*d22 .

3. displayFlower() that shows the information of the flower (color and area).

----------------------------------------------------------------------------------------------------------------

Question 2:

In the main method:

Create an object f1 of flower type.

Fill the fields of f1.

Compute the area of the f1's petal.

Show the information of f1.

Create an object f2 of flower type with values ("green",3.5 , 1.5) from the constructor.

Compute the area of the f2's petal.

Show the information of f2.

------------------------------------------------------------------------------------------------------------------------

Question 3:

Now, we want to create many flowers, to do that:

Create an array of 5 flowers.

Fill these flowers.

Compute their areas.

Show their colors and their areas.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

a. When did your ancestors come to the United States?

Answered: 1 week ago

Question

d. What language(s) did they speak?

Answered: 1 week ago

Question

e. What difficulties did they encounter?

Answered: 1 week ago