MINDTAPV2.0 JAVA PROGRAMMING 2021, 1TERM
MINDTAPV2.0 JAVA PROGRAMMING 2021, 1TERM
9th Edition
ISBN: 9780357505526
Author: FARRELL
Publisher: CENGAGE L
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
0o.Absolutely answer please Write a program that calculates the average of courses, overall grade, and letter grade. Suppose that your students take four courses - English, Mathematics, Science, and History. You should design a class that accepts all four course's numeric scores, calculates average and overall grade, and decides letter grade based on the overall grade. Your class should have a constructor, get and set methods of each course, a method that calculates the average of four courses, a method that calculates overall grade, and a method that decides letter grade. The overall grades are calculated as the following rate: Average of All four courses: 50% Quiz: 40% Attendance: 10% The letter grade is based on the following: 90.0 to 100.0 - A 80.0 to 89.9 - B 70.0 to 79.9 - C 65.0 to 69.9 - D less than 65 - F Your program demonstrates the class by asking the user to input four-course numeric scores, creating an object, and then reporting each course's score, average, overall…
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…
Thanks in advance. Modify a class named Circle with fields named radius, diameter, and area. Include a constructor that sets the radius to 1 and calculates the other two values. Also include methods named setRadius() and getRadius(). The setRadius() method not only sets the radius, but it also calculates the other two values. (The diameter of a circle is twice the radius, and the area of a circle is pi multiplied by the square of the radius. Use the Math class PI constant for this calculation.) class Circle {private double radius;private double area;private double diameter;Circle() {}public void setRadius(double r) {}public double getRadius() {}private void computeDiameter() {}private void computeArea() {}public double getDiameter() {}public double getArea() {}} class TestCircle {public static void main (String args[]) {Circle a = new Circle();Circle b = new Circle();Circle c = new Circle(); a.setRadius(1.5);b.setRadius(1500.50); System.out.println("The area of a is "…
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