Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =======================================================================================================================================
- Ciecle
- =======================================================================================================================================
- /*
- *File name: Circle.java
- *
- *Programmer: Derek Townsend
- *ULID: djtown1
- *
- *Date: Sep 18, 2017
- *
- *Class: IT 168
- *Lecture Section: 004
- *Lecture Instructor:Dr Xing Fang
- *Lab Section: 005
- *Lab Instructor: Simran Kaur
- */
- package edu.ilstu;
- /*
- *<insert description>
- *
- * @author Derek
- *
- */
- public class Circle
- {
- // Scanner scan = new Scanner(System.in);
- private double radius;
- private final double PI;
- double area,diameter,circumference;
- public Circle(){
- PI= 3.14159;
- }
- public double calculateArea(){
- area=PI*radius*radius;
- return area;
- }
- public double calculateDiameter(){
- diameter=2*PI*radius;
- return diameter;
- }
- public double calculateCircumference(){
- circumference=2*PI*radius;
- return circumference;
- }
- public void setRadius(double radius) {
- this.radius=radius;
- }
- public double getRadius(){
- return radius;
- }
- }
- =======================================================================================================================================
- circle driver
- =======================================================================================================================================
- /*
- *File name: CircleDriver.java
- *
- *Programmer: Derek Townsend
- *ULID: djtown1
- *
- *Date: Sep 18, 2017
- *
- *Class: IT 168
- *Lecture Section: 004
- *Lecture Instructor:Dr Xing Fang
- *Lab Section: 005
- *Lab Instructor: Simran Kaur
- */
- package edu.ilstu;
- import java.util.Scanner;
- /*
- *<insert description>
- *
- * @author Derek
- *
- */
- public class CircleDriver
- {
- Scanner scan = new Scanner(System.in);
- public static void main(String[]args) {
- double radius=scan.nextDouble();
- System.out.print("Enter the radius of a circle: ");
- Circle circleOne = new Circle();
- // circleOne.getRadius();
- circleOne.setRadius(radius);
- circleOne.calculateArea();
- circleOne.calculateDiameter();
- circleOne.calculateCircumference();
- System.out.println("Area = "+circleOne.calculateArea());
- System.out.println("Area = "+circleOne.calculateDiameter());
- System.out.println("Area = "+circleOne.calculateCircumference());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement