Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Java Programming (Class Assignment)

julesxdujour
julesxdujour 


Write a Circle class that has the following fields: radius: a double PI: a final double initialized with the value 3.14159 The class should have the following methods: Constructor: Accepts the radius of the circle as an argument Constructor: A no-arg constructor that sets the radius field to 0.0 setRadius: A mutator method for the radius field getRadius: An accessor method for the radius field getArea: Returns the area of the circle, which is calculated as are = PI * radius * radius getDiameter: Returns the diameters of the circle, which is calculated a diameter = radius * 2 getCircumference: Returns the circumference of the circle, which is calculated as circumference = 2 * PI * radius Write a program that demonstrate the Circle class by asking the user for the circle's radius, creating a Circle object, and then reporting the circle's area, diameter, and circumference. Attachments
Tags Clarifications

Answers

Circle - Java

dickersonka
dickersonka 



Circle java eclipse project... Attachments
Circle.zip (3 K) Download





Preview
private double radius; //Pi constant private static final double PI = 3.14159; /** * Circle Constructor */ public Circle(){ //Initialize radius this.radius = 0.0; } /** * Circle Constructor * @param radius - radius

Preview
public static void main(String[] args){ Scanner scanner = new Scanner(System.in); //Prompt for radius System.out.print("Enter radius of circle: "); //Get

Screenshots
Purchase Answer