Advertisement
Anthei

Program7CircleClass

Oct 22nd, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. /* Eva Goins
  2.  * Chapter 6
  3.  * Description: Utilizes class Circle to create a circle. Gets
  4.  *      user input for the circle radius in order to use methods
  5.  *      getArea, getDiameter, and getCircumference to calculate
  6.  *      the area, diameter, and circumference respectively.
  7.  *      Displays the area, diameter, and circumference after
  8.  *      calculating.
  9.  */
  10.  
  11.  import java.util.Scanner;
  12.  
  13.  public class Program7CircleClass
  14.  {
  15.     public static void main(String[] args)
  16.     {
  17.         Scanner keyin = new Scanner(System.in);
  18.         Circle myCircle = new Circle();
  19.         double rad;
  20.        
  21.         System.out.print("Input a radius: ");
  22.         rad = keyin.nextDouble();
  23.        
  24.         myCircle.setRadius(rad);
  25.        
  26.         System.out.printf("The area is %.2f \n", myCircle.getArea());
  27.         System.out.printf("The diameter is %.2f \n", myCircle.getDiameter());
  28.         System.out.printf("The circumference is %.2f \n",
  29.             myCircle.getCircumference());
  30.     }
  31.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement