Question

A. Create a new Class called "Lab6-3" B. Declare variables for the radius, perimeter, and area....

A. Create a new Class called "Lab6-3"
B. Declare variables for the radius, perimeter, and area.
C. Initialize perimeter and area to zero.
D. Initialize radius to a number of your choice.
E. Calculate perimeter and area.
F. Print the perimeter and area on separate lines.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
// A. Create a new Class called "Lab6-3"
public class Lab6_3 {

    public static void main(String[] args) {
        // B. Declare variables for the radius, perimeter, and area.
        double radius, perimeter, area;

        // C. Initialize perimeter and area to zero.
        perimeter = 0;
        area = 0;

        // D. Initialize radius to a number of your choice.
        radius = 10;

        // E. Calculate perimeter and area.
        perimeter = 2 * Math.PI * radius;
        area = Math.PI * radius * radius;

        // F. Print the perimeter and area on separate lines.
        System.out.println("Area = " + area);
        System.out.println("Perimeter = " + perimeter);
    }
}
Add a comment
Know the answer?
Add Answer to:
A. Create a new Class called "Lab6-3" B. Declare variables for the radius, perimeter, and area....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In a project named 'DogApplication', create a class called 'Dog' 1. declare two instance variables in...

    In a project named 'DogApplication', create a class called 'Dog' 1. declare two instance variables in 'Dog' : name (String type) age (int type) 2. declare the constructor for the 'Dog' class that takes two input parameters and uses these input parameters to initialize the instance variables 3. create another class called 'Driver' and inside the main method, declare two variables of type 'Dog' and call them 'myDog' and 'yourDog', then assign two variables to two instance of 'Dog' with...

  • Create a new package in assignment called shapes. All work for this part should be done...

    Create a new package in assignment called shapes. All work for this part should be done in the shapespackage. Create a new interface called Shape. Add double area() and double perimter()methods to the Shape interface. Create two classes called Circle and Rectanglewhich implement Shape. Add reasonable fields to the Circle and Rectangle classes which will allow you to calculate the area and perimeter of each shape. Add constructors to Circle and Rectangle so you can initialize your fields. Implement the...

  • Using separate files, write the definition for a class called Point and a class called Circle. Th...

    Using separate files, write the definition for a class called Point and a class called Circle. The class point has the data members x (double) and y (double) for the x and y coordinates. The class has the following member functions: a) void set_x(double) to set the x data member b) void set_y(double) to set the y data member c) double get_x() to return the the x data member d) double get_y() to return the the y data member e)...

  • Create a Ruby class Cylinder. Each cylinder is characterized by the instance variables radius and height. For this class...

    Create a Ruby class Cylinder. Each cylinder is characterized by the instance variables radius and height. For this class the initializer/constructor and the method volume that returns the volume of the cylinder. For this class the initializer/constructor and the method area that returns the area of cylinder. Create a class Can that inherits properties from the class Cylinder and adds new instance variablescontents(e.g. beer, Pepsi, Coke) and price(real number). Initialize an array of cans and write Ruby code necessary to...

  • java language Problem 3: Shape (10 points) (Software Design) Create an abstract class that represents a Shape and contains abstract method: area and perimeter. Create concrete classes: Circle, Rectang...

    java language Problem 3: Shape (10 points) (Software Design) Create an abstract class that represents a Shape and contains abstract method: area and perimeter. Create concrete classes: Circle, Rectangle, Triangle which extend the Shape class and implements the abstract methods. A circle has a radius, a rectangle has width and height, and a triangle has three sides. Software Architecture: The Shape class is the abstract super class and must be instantiated by one of its concrete subclasses: Circle, Rectangle, or...

  • Q2) Interface Create a program that calculates the perimeter and the area of any given 2D...

    Q2) Interface Create a program that calculates the perimeter and the area of any given 2D shape. The program should dynamically assign the appropriate calculation for the given shape. The type of shapes are the following: • Quadrilateral 0 Square . Perimeter: 4xL • Area:LXL O Rectangle • Perimeter: 2(L+W) • Area:LxW Circle Circumference: I x Diameter (TT = 3.14) Area: (TT xD')/4 Triangle (assume right triangle) o Perimeter: a+b+c O Area: 0.5 x base x height (hint: the base...

  • Using Python Write the following well-documented (commented) program. Create a class called Shape that has a...

    Using Python Write the following well-documented (commented) program. Create a class called Shape that has a method for printing the area and the perimeter. Create three classes (Square, Rectangle, and Circle) which inherit from it. Square will have one instance variable for the length. Rectangle will have two instance variables for the width and height. Circle will have one instance variable for the radius. The three classes will have methods for computing the area and perimeter of its corresponding shape....

  • // Group Names: // Date: // Program Description: //   Import required packages //--> //   Declare class...

    // Group Names: // Date: // Program Description: //   Import required packages //--> //   Declare class (SwitchDoLab) //--> {    //   Declare the main method    //-->    {        //   Declare Constant integers SUM = 1, FACTORIAL = 2, QUIT = 3.        //-->        //-->        //-->        //   Create an integer variable named choice to store user's option.        //-->        //   Create a Scanner object        //   Create...

  • Create a class Circle with one instance variable of type double called radius. Then define an...

    Create a class Circle with one instance variable of type double called radius. Then define an appropriate constructor that takes an initial value for the radius, get and set methods for the radius, and methods getArea and getPerimeter. Create a class RightTriangle with three instance variables of type double called base, height, and hypotenuse. Then define an appropriate constructor that takes initial values for the base and height and calculates the hypotenuse, a single set method which takes new values...

  • This exercise guides you through the process of converting an Area and Perimeter application from a...

    This exercise guides you through the process of converting an Area and Perimeter application from a procedural application to an object-oriented application. Create and use an object 1. Open the project named ch04_ex2_Area and Perimeter that’s stored in the ex_starts folder. Then, review the code for the Main class. 2. Create a class named Rectangle and store it in the murach.rectangle package. 3. In the Rectangle class, add instance variables for length and width. The, code the get and set...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT