Advertisement
Anthei

Modified CircleClass

Oct 22nd, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.73 KB | None | 0 0
  1.     /* Jaclyn Jardell
  2.      * Chapter 6 Programming
  3.      * This program will have fields that are private and methods that are public.
  4.      * Overall, this program will ask the user to input a radius of the circle.
  5.      * With that radius will calculate the circles, area, diameter, and circumference.
  6.      */
  7.     import java.util.Scanner;
  8.     public class CircleClass
  9.     {
  10.             /*Here's prob #1: Your CircleClass is supposed to have its own file.
  11.              *A CLASS file should be completely separate from the APPLICATION file
  12.              *that calls it. Once you've moved all the class stuff to its own file,
  13.              *create an object by doing this:
  14.              *[CircleClassFileName] [variableName] = new [CircleClassFileName](rand);
  15.              *Everything inside a bracket is something YOU decide to name it! Remember
  16.              *to name it something SEPARATE from what this file is called!*/
  17.             public static void main (String [] args)
  18.             {
  19.                    /*Everything after this line to the end of the comment goes in
  20.                     *a separate file (IN the same folder!)
  21.                      
  22.                     private double radius;
  23.                     private final double PI = 3.14159;
  24.                     Scanner keyin = new Scanner (System.in);
  25.      
  26.                     public  void CircleClass(double rand)
  27.                     {
  28.                             radius = rand;
  29.                     }
  30.                     public void CircleClass()
  31.                     {
  32.                             rand = 0.0;
  33.                     }
  34.                     public void setRadius(double rand)
  35.                     {
  36.                             radius = rand;
  37.                     }
  38.                     public double getRaduis()
  39.                     {
  40.                             return radius;
  41.                     }
  42.                     public double getArea()
  43.                     {
  44.                             return PI * radius * radius;
  45.                     }
  46.                     public double getDiameter()
  47.                     {
  48.                             return radius * 2;
  49.                     }
  50.                     public double getCircumference()
  51.                     {
  52.                             return 2 * PI * radius;
  53.                     }
  54.                     **/
  55.                    
  56.                     System.out.println("What is the radius?");
  57.                     rand = keyin.nextDouble();
  58.                     myCircle.setRadius(rand);
  59.                     System.out.println("The area is" + (myCircle.getArea));
  60.                     System.out.println("The diameter is" + (myCircle.getDiameter));
  61.                     System.out.println("The circumference is" + (myCircle.getCircumference));
  62.             }
  63.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement