MindTapV2.0 for Farrell's Java Programming with 2021 Updates, 9th Edition [Instant Access], 1 term
MindTapV2.0 for Farrell's Java Programming with 2021 Updates, 9th Edition [Instant Access], 1 term
9th Edition
ISBN: 9780357505540
Author: Farrell; Joyce
Publisher: Cengage Learning US
Question
Book Icon
Chapter 4, Problem 6PE
Program Plan Intro

Calculate the area and diameter of Circle

Program plan:

Filename: “Circle.java”

  • Define the “Cirle” class
    • Declare the required variables.
    • Define constructor
      • Set the radius value as 1.
      • Call the “calc” method.
    • Define the “setRadius” method
      • Set the value
      • Call the “calc” method
    • Define the “getRadius” method
      • Return the radius
    • Define the “getDiameter” method
      • Return the diameter
    • Define the “getArea” method
      • Return the area
    • Define the “calc” method
      • Calculate the diameter of the circle
      • Calculate the area of the circle.

Filename: “TestCircle.java”

  • Define the “TestCircle” class
    • Define the main method.
      • Create the objects for “Circle” class
      • Call the “setRadius” method with different values
      • Call the “display” method
    • Define the “display” method
      • Display the radius, diameter, and area of the circle.

Blurred answer
Students have asked these similar questions
Create a class called Point which will have 2 co-ordinate value x & y and will be able to calculate the distance between two points. Write appropriate constructor and method of the class. Create another class called Shape, which takes different number of points to create a triangle, rectangle and circle. And also able to calculate the area and perimeter for the different shapes. Write the appropriate overloading method for this shape class. Write appropriate main function to test the shape class. (Use C++ only for code)
Create a class called Point which will have 2 co-ordinate value x & y and will be able to calculate the distance between two points. Write appropriate constructor and method of the class. Create another class called Shape, which takes different number of points to create a triangle, rectangle and circle. And also able to calculate the area and perimeter for the different shapes. Write the appropriate overloading method for this shape class. Write appropriate main function to test the shape class.   (Use C++ )
Instructions This assignment must follow directions exactly. Create a class Lab02 with a main method, and put all of the following code into the main method: Print the prompt shown below and ask the user for the number of exemptions. The number of exemptions is an integer. Print the prompt shown below and ask the user for their gross salary. The gross salary represents dollars, which can be entered with or without decimal points. Print the prompt shown below and ask the user for their interest income. The interest income represents dollars, which can be entered with or without decimal points. Print the prompt shown below and ask the user for their capital gains income. The capital gains represents dollars, which can be entered with or without decimal points. Print the prompt shown below and ask the user for the amount of charitable contributions. The charitable contributions represents dollars, which can be entered with or without decimal points. Perform the calculation of…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT