Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Jaclyn Jardell
- * Chapter 6 Programming
- * This program will have fields that are private and methods that are public.
- * Overall, this program will ask the user to input a radius of the circle.
- * With that radius will calculate the circles, area, diameter, and circumference.
- */
- import java.util.Scanner;
- public class CircleClass
- {
- /*Here's prob #1: Your CircleClass is supposed to have its own file.
- *A CLASS file should be completely separate from the APPLICATION file
- *that calls it. Once you've moved all the class stuff to its own file,
- *create an object by doing this:
- *[CircleClassFileName] [variableName] = new [CircleClassFileName](rand);
- *Everything inside a bracket is something YOU decide to name it! Remember
- *to name it something SEPARATE from what this file is called!*/
- public static void main (String [] args)
- {
- /*Everything after this line to the end of the comment goes in
- *a separate file (IN the same folder!)
- private double radius;
- private final double PI = 3.14159;
- Scanner keyin = new Scanner (System.in);
- public void CircleClass(double rand)
- {
- radius = rand;
- }
- public void CircleClass()
- {
- rand = 0.0;
- }
- public void setRadius(double rand)
- {
- radius = rand;
- }
- public double getRaduis()
- {
- return radius;
- }
- public double getArea()
- {
- return PI * radius * radius;
- }
- public double getDiameter()
- {
- return radius * 2;
- }
- public double getCircumference()
- {
- return 2 * PI * radius;
- }
- **/
- System.out.println("What is the radius?");
- rand = keyin.nextDouble();
- myCircle.setRadius(rand);
- System.out.println("The area is" + (myCircle.getArea));
- System.out.println("The diameter is" + (myCircle.getDiameter));
- System.out.println("The circumference is" + (myCircle.getCircumference));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement