Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. The NetBeans project contains, in the package pa7, two files. These are (a) Circle.java - This file contains an abbreviated version of class Circle,

2. The NetBeans project contains, in the package pa7, two files. These are (a) "Circle.java" - This file contains an abbreviated version of class Circle, i. e. it just has a radius that must be 0 or greater. (b) "PA7.java - This file contains the class PA7, which is where you will write your code. 3. Study class Circle so that you understand how to create instances and reference variables of class Circle and are able to call the methods of class Circle. 4. In class PA7, create a public static Java method that receives an ArrayList and returns the total area in all the Circle objects referenced in the ArrayList. 5. In the main method of class PA7, write the Java code that (a) creates an ArrayList instance object and its reference variable. (b) prompts for and receives from the user the number of circles to store in the ArrayList. (c) prompts for and receives from the user the radii for the number of circles indicated in (b), then create a Circle instance object for each radius, adding each Circle object to the ArrayList. (d) calculates the total area of the circles in the ArrayList by passing the ArrayList to the method created in (4). (e) uses calls to methods of the ArrayList and the value returned from the method that calculates the total area of the circles in the ArrayList to i. output the number of circles stored in the ArrayList. ii. output the total area of the circles stored in the ArrayList. iii. output the average area of the circles stored in the ArrayList. iv. list the radii of the circles stored in the ArrayList.

Class Circle---

package pa7;

public class Circle {

private double radius = 0;

public Circle() { } public Circle(double radius) { setRadius(radius); } public double getRadius() { return radius; }

public void setRadius(double radius) { if (radius > 0) this.radius = radius; }

@Override public String toString() { return "(" + radius + ")"; } }

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

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

What is job description ? State the uses of job description.

Answered: 1 week ago

Question

What are the objectives of job evaluation ?

Answered: 1 week ago

Question

Write a note on job design.

Answered: 1 week ago

Question

Compute the derivative of f(x)cos(-4/5x)

Answered: 1 week ago