EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
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 named Lease with fields that hold an apartment tenant’s name, apartmentnumber, monthly rent amount, and term of the lease in months. Include a constructor thatinitializes the name to “XXX”, the apartment number to 0, the rent to 1000, and the term to12. Also include methods to get and set each of the fields. Include a nonstatic methodnamed addPetFee() that adds $10 to the monthly rent value and calls a static methodnamed explainPetPolicy() that explains the pet fee. Save the class asLeaseYourlastname.java. Replace ‘Yourlastname’ with your real last name.b) Create a class named TestLease whose main() method declares four Lease objects. Call agetData() method three times. Within the method, prompt a user for values for each fieldfor a Lease, and return a Lease object to the main() method where it is assigned to one ofmain()’s Lease objects. Do not prompt the user for values for the fourth Lease object, but letit continue to hold the default values. Then, in main(), pass…
Create a class named Checkup with fields that hold a patient number, two blood pressure figures (systolic and diastolic), and two cholesterol figures (LDL and HDL). Include methods to get and set each of the fields. Include a method named computeRatio() that divides LDL cholesterol by HDL cholesterol and displays the result. Include an additional method named explainRatio() that explains that HDL is known as “good cholesterol” and that a ratio of 3.5 or lower is considered optimum. Save the class as CheckupType.cpp. Create a tester program named TestCheckup whose main() method declares four Checkup objects. Call a getData() method four times. Within the method, prompt a user for values for each field for a Checkup, and return a Checkup object to the main() method where it is assigned to one of main()’s Checkup objects. Then, in main(), pass each Checkup object in turn to a showValues()method that displays the data. Blood pressure values are usually displayed with a slash between the…
create a class named checkup with fields that you read a patient number, blood pressure figures (systolic or diastolic), and two cholesterol figures (ldl and hdl). include a method named computeratio() that divides ldl cholesterol by hdl cholesterol and displays the result. include an additional method named explainratio() that explains that hdl is knowns as “good cholesterol” and that a ratio of 3.5 or lower is considered optimum pseudo code
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
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage