Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started