Recitation R9
- File Input & Output
Summer 2016
CS160: Foundations in Programming
Circle Class
Create the following instance variables and methods inside your Circle class
- One instance variables of type double named radius.
- A constructor that takes one parameter and assigns that value to the instance variable.
- a private non-static method called area that has no parameters and returns a double.
- The area of a circle is:
- You can use Math.PI from the Math class for the equation.
- a toString method that returns the following:
Circle, (Radius: #), Area: #
Radius and Area should be formatted to 2 decimal places.
Testing
To make sure your Circle class is printing what you want it to print. Create a Triangle object in your main method using the following code:
Circle shape = new Circle(5.5);
System.out.println(shape);
© 2015 CS160 Colorado State University. All Rights Reserved.