Write an ADT named Circle Include data radius double PI a co

Write an ADT named Circle:

Include data:

radius (double)

PI (a constant double initialized with 3.14159)

Include methods:

A no-argument constructor

A constructor that sets the data to passed values

Getters and setters for each piece of data

getArea (PI * radius * radius … try using a Math method here)

getDiameter (radius * 2)

getCircumference (2 * PI * radius)

A toString( ) method to display the object data

Include Javadoc comments for the class and every method, and generate the Javadoc/API

Create a separate Java application to “unit test” this class (zyBook section 6.6) by creating 3 objects: create one using the default constructor, and create the other two using radius values you get as input from the user.

Write an ADT named BankCharges:

Include data:

beginning balance

number of checks written

Include all necessary/basic methods, plus a method to calculate and return the bank’s service fees for the month. The bank charges $10 per month, an additional $15 extra if the balance falls below $400, plus the following check fees:

.10 each for less than 20 checks

.08 each for 20-39 checks

.06 each for 40-59 checks

.04 each for 60 or more checks

Include Javadoc comments for the class and every method, and generate the Javadoc/API

Create a separate Java application to “unit test” this class (zyBook section 6.6) by creating 2 objects. Ask the user to input the beginning balance and number of checks written values, then use those values to instantiate your objects. Make sure to test all of the check fee amounts (hint: use the ‘set’ method to change the number of checks written and then call service fee calculation method).

Solution

Hi Friend, I have answered Q1.

Please repost others in separate post.

Please let me know in case of any issue.

############ Circle.java #################

/**

* @author pravesh

*

*/

public class Circle {

  

   // instance variables

   private double radius;

   private static final double PI = 3.14159;

  

   // constructors

   public Circle() {

       radius = 0;

   }

   /**

   * @param radius

   */

   public Circle(double radius) {

       this.radius = radius;

   }

   // getters and setters

  

   /**

   * @return radius

   */

   public double getRadius() {

       return radius;

   }

   /**

   * @param radius

   */

   public void setRadius(double radius) {

       this.radius = radius;

   }

  

   /**

   * @return area

   */

   public double getArea(){

       return PI*radius*radius;

   }

  

   /**

   * @return diameter

   */

   public double getDiameter(){

       return 2*radius;

   }

  

   /**

   * @return perimeter

   */

   public double getCircumference(){

       return 2*PI*radius;

   }

  

   /* (non-Javadoc)

   * @see java.lang.Object#toString()

   */

   @Override

   public String toString() {

       return \"Radius: \"+radius;

   }

}

############## CircleTest.java ################

public class CircleTest {

  

   public static void main(String[] args) {

      

       //Creating Objects of Circle

      

       Circle c1 = new Circle();

      

       c1.setRadius(4.5);

      

       System.out.println(\"Area: \"+c1.getArea());

       System.out.println(\"Diameter: \"+c1.getDiameter());

       System.out.println(\"Circumference: \"+c1.getCircumference());

      

       Circle c2 = new Circle(5.6);

       System.out.println(\"Radius: \"+c2.getRadius());

       System.out.println(\"Area: \"+c2.getArea());

       System.out.println(\"Diameter: \"+c2.getDiameter());

       System.out.println(\"Circumference: \"+c2.getCircumference());

   }

}

/*

Sample run:

Area: 63.6171975

Diameter: 9.0

Circumference: 28.27431

Radius: 5.6

Area: 98.52026239999998

Diameter: 11.2

Circumference: 35.185807999999994

*/

Write an ADT named Circle: Include data: radius (double) PI (a constant double initialized with 3.14159) Include methods: A no-argument constructor A constructo
Write an ADT named Circle: Include data: radius (double) PI (a constant double initialized with 3.14159) Include methods: A no-argument constructor A constructo
Write an ADT named Circle: Include data: radius (double) PI (a constant double initialized with 3.14159) Include methods: A no-argument constructor A constructo
Write an ADT named Circle: Include data: radius (double) PI (a constant double initialized with 3.14159) Include methods: A no-argument constructor A constructo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site