Answer:
public static double circleArea(double radius){
double area = 3.142*Math.pow(radius,2);
return area;
}
Explanation:
Find the complete program in java that prompts the user to enter a value for radius, stores it in a variable, calls the method circleArea() and passes the value for the radius, then displays the area.
import java.util.Scanner;
public class CocaColaVendingTest {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Please enter the value for radius");
double r = in.nextDouble();
//Calling the method circleArea()
double calcArea = circleArea(r);
System.out.println("The Area is: "+calcArea);
}
public static double circleArea(double radius){
double area = 3.142*Math.pow(radius,2);
return area;
}
}