Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.41 KB | None | 0 0
  1. =======================================================================================================================================
  2. Ciecle
  3. =======================================================================================================================================
  4.  
  5. /*
  6.  *File name: Circle.java
  7.  *
  8.  *Programmer: Derek Townsend
  9.  *ULID: djtown1
  10.  *
  11.  *Date: Sep 18, 2017
  12.  *
  13.  *Class: IT 168
  14.  *Lecture Section: 004
  15.  *Lecture Instructor:Dr Xing Fang
  16.  *Lab Section: 005
  17.  *Lab Instructor: Simran Kaur
  18.  */
  19.  
  20. package edu.ilstu;
  21.  
  22. /*
  23.  *<insert description>
  24.  *
  25.  * @author Derek
  26.  *
  27.  */
  28.  
  29. public class Circle
  30. {
  31. //  Scanner scan = new Scanner(System.in);
  32.      private double radius;
  33.      private final double PI;
  34.      double area,diameter,circumference;
  35.      
  36.      public Circle(){
  37.          PI= 3.14159;
  38.      }
  39.     public double calculateArea(){
  40.         area=PI*radius*radius;
  41.         return area;
  42.     }
  43.     public double calculateDiameter(){
  44.         diameter=2*PI*radius;
  45.         return diameter;
  46.     }
  47.     public double calculateCircumference(){
  48.         circumference=2*PI*radius;
  49.         return circumference;
  50.     }
  51.     public void setRadius(double radius) {
  52.         this.radius=radius;
  53.     }
  54.     public double getRadius(){
  55.         return radius;
  56.     }
  57.    
  58.    
  59. }
  60. =======================================================================================================================================
  61. circle driver
  62. =======================================================================================================================================
  63. /*
  64.  *File name: CircleDriver.java
  65.  *
  66.  *Programmer: Derek Townsend
  67.  *ULID: djtown1
  68.  *
  69.  *Date: Sep 18, 2017
  70.  *
  71.  *Class: IT 168
  72.  *Lecture Section: 004
  73.  *Lecture Instructor:Dr Xing Fang
  74.  *Lab Section: 005
  75.  *Lab Instructor: Simran Kaur
  76.  */
  77.  
  78. package edu.ilstu;
  79. import java.util.Scanner;
  80.  
  81.  
  82. /*
  83.  *<insert description>
  84.  *
  85.  * @author Derek
  86.  *
  87.  */
  88.  
  89. public class CircleDriver
  90. {
  91.     Scanner scan = new Scanner(System.in);
  92.    
  93.     public static void main(String[]args) {
  94.     double radius=scan.nextDouble();
  95.     System.out.print("Enter the radius of a circle:  ");
  96.    
  97.     Circle circleOne = new Circle();
  98. //  circleOne.getRadius();
  99.     circleOne.setRadius(radius);
  100.     circleOne.calculateArea();
  101.     circleOne.calculateDiameter();
  102.     circleOne.calculateCircumference();
  103.     System.out.println("Area =  "+circleOne.calculateArea());
  104.     System.out.println("Area =  "+circleOne.calculateDiameter());
  105.     System.out.println("Area =  "+circleOne.calculateCircumference());
  106.     }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement