Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Advanced Java Programming with Object-Oriented Programming Design VERY IMPORTANT

ID: 3724805 • Letter: A

Question

Advanced Java Programming with Object-Oriented Programming Design

VERY IMPORTANT NOTE!!: This program for the question below MUST USE at least 2 CLASSES, getters/setters, etc and other object-oriented design (OOD) concepts because I'm in a more advanced Java class that requires me to utilize the concepts mentioned above. Also, I need detailed, but brief comments to most, if not all of the code to explain what is being used in the code and what is does so I have a better understanding of the code. I've seen answers to the question below already posted, however they don't utilize object-oriented design (OOD) concepts such as a minumum of two classes, getters/setters, etc which is required for this advanced Java programming class. So please......answer the question and meet the requirements for this question. Basically, I need advanced Java object-oriented design concepts for simple programs so here's to hoping this works out and if it does, I'll give a thumbs up, I promise!!!

Write an application that prompts the user for the radius of a circle and uses a method called circleArea to calculate the area of the circle.

Explanation / Answer

Circle.java

public class Circle {

//Declaring instance variables

private double radius;

//Parameterized constructor

public Circle(double radius) {

this.radius = radius;

}

//getters and setters

public double getRadius() {

return radius;

}

public void setRadius(double radius) {

this.radius = radius;

}

//This method will calculate the area of the circle

public double calculateArea() {

return Math.PI * radius * radius;

}

}

__________________

Test.java

import java.util.Scanner;

public class Test {

public static void main(String[] args) {

double radius;

/*

* Creating an Scanner class object which is used to get the inputs

* entered by the user

*/

Scanner sc = new Scanner(System.in);

//Getting the input entered by the user

System.out.print("Enter the radius of the Circle :");

radius=sc.nextDouble();

//Creating an instance of Circle

Circle c=new Circle(radius);

//Displaying the area of the Circle

System.out.printf("Area fo the Circle :%.2f ",c.calculateArea());

}

}

__________________

Output:

Enter the radius of the Circle :5.5
Area fo the Circle :95.03

______________Thank You

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote