Question: question Modify driver class CircleStats1.java and blueprint class Circle.java, by inserting code appropriately in the lines indicated by asterisks. in java thank you with clear
question
- Modify driver class CircleStats1.java and blueprint class Circle.java, by inserting code appropriately in the lines indicated by asterisks. in java thank you with clear comments
/** * CircleStats calculates the area and circumference of a circle, given its radius. */ import java.util.Scanner; public class CircleStats1 { /** * Input (from the user): radius * Output (to the screen): area and circumference of a circle with the given radius */ public static void main (String[] args) { // Declare variables double radius, area, circumference; // Set up Scanner object Scanner keyboard = new Scanner (System.in); // Input a radius from the user. System.out.print ("Enter the radius of a circle: "); radius = keyboard.nextDouble (); // Create a Circle object (circ) with the given radius. Circle circ = new Circle (radius); // Calculate the area and circumference by invoking the appropriate methods on circ. area = ***** Call appropriate method of Circle class here ****** circumference = ***** Call appropriate method of Circle class here ***** // Print the area and circumference of the circle with the given radius. System.out.println ("A circle with a radius of " + radius + " has an area of " + area + " and a circumference of " + circumference); } // end main } // end CircleStats blueprint class circle
//******************************************************************** // Circle.java Author: // // Represents one circle with a radius. //******************************************************************** public class Circle { private final double PI = 3.14; private double radius; //----------------------------------------------------------------- // Constructor: Sets the initial radius. //----------------------------------------------------------------- public Circle(double radiusVal) { this.radius = radiusVal; // "this." is optional but makes the code more readable by saying here that radius is a state variable (a.k.a. attribute) as opposed to some other kind of variable. } // end of constructor //----------------------------------------------------------------- // Compute the area and return the result. //----------------------------------------------------------------- public double computeArea() { double result; result = ***** INSERT CODE HERE ***** return result; } // end of method computeArea() //----------------------------------------------------------------- // Compute the circumference and return the result. //----------------------------------------------------------------- public double computeCircumference() { double result; result = ***** INSERT CODE HERE ***** return result; } // end of method computeCircumference() } // end of class Circle
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
