Question

Write a JAVA method called printComputeArea that receives the radius of a circle as an argument...

  1. Write a JAVA method called printComputeArea that receives the radius of a circle as an argument and prints its area

Homework Answers

Answer #1

ANSWER: Here I am giving you the code and output please like it or comment your doubt if you have any.

CODE:

import java.util.Scanner;
class Main
{
public static void printComputeArea(double radius){
double area = Math.PI * (radius * radius);
System.out.printf("The area of circle is:%.4f ", area);
}
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the radius: ");
  
double radius = sc.nextDouble();
printComputeArea(radius);
  
}
}

OUTPUT:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
java Consider the following class definition: public class Circle { private double radius; public Circle (double...
java Consider the following class definition: public class Circle { private double radius; public Circle (double r) { radius = r ; } public double getArea(){ return Math.PI * radius * radius; } public double getRadius(){ return radius; } } a) Write a toString method for this class. The method should return a string containing the radius and area of the circle; For example “The area of a circle with radius 2.0 is 12.1.” b) Writeaequalsmethodforthisclass.ThemethodshouldacceptaCircleobjectasan argument. It should return...
Write a method that returns the area of a circle given the radius. Use the Math.PI...
Write a method that returns the area of a circle given the radius. Use the Math.PI method.
Write a C# source code. Write a function called CircArea() that finds the area of a...
Write a C# source code. Write a function called CircArea() that finds the area of a circle. It should take an argument of type double and return an argument of the same type. Write a Main() method that gets a radius value from the user, calls CircArea(), and displays the result.
Write a method that accepts a String object as an argument and displays its contents backward....
Write a method that accepts a String object as an argument and displays its contents backward. For instance, if the string argument is "gravity" the method should display "ytivarg". Demonstrate the method in a program that asks the user to input a string and then prints out the result of passing the string into the method. Sample Run java BackwardString Enter·a·string:Hello·world↵ dlrow·olleH↵
Java Lab Assignment Write a method called convertToArray. The method will take a String as an...
Java Lab Assignment Write a method called convertToArray. The method will take a String as an argument and it will return an array of chars. Each index of the String will be stored in each index of the array. method must be well documented using JavaDoc, example: /** * The find method checks if the target in the array * @param String [] a - array of Strings * @param String t - value to be searched for * @return...
Java Lab Assignment Write a method called convertToString. The method will take an array of chars...
Java Lab Assignment Write a method called convertToString. The method will take an array of chars as an argument and it will return a String. Each index of the array will be part of the each index of the String. method must be well documented using JavaDoc, example: /** * The find method checks if the target in the array * @param String [] a - array of Strings * @param String t - value to be searched for *...
(in java) a. Include a good comment when you write the method described below: Write a...
(in java) a. Include a good comment when you write the method described below: Write a method factorial which receives a positive integer n and calculates n! (n factorial), defined as follows: n!=1*2*…*(n-1)*n. For example, 5! = 1*2*3*4*5 = 120. The method should return this value to the calling program. b. Write a driver program (main method) which will read an integer from the console, and pass it to the method to calculate its factorial. The main method then prints...
Create a java class called Timer which contains a method called Display that prints a counter...
Create a java class called Timer which contains a method called Display that prints a counter beginning at 00:00 and increments second and minute by minute until it stops at a total of 60 minutes.
In JAVA Write a RECURSIVE method that receives as a parameter an integer named n. The...
In JAVA Write a RECURSIVE method that receives as a parameter an integer named n. The method will output n # of lines of stars. For example, the first line will have one star, the second line will have two stars, and so on. The line number n will have "n" number of ****** (stars) so if n is 3 it would print * ** *** The method must not have any loops!
How do you code in Java a method (lets say its called PosOddAverage) that: - Takes...
How do you code in Java a method (lets say its called PosOddAverage) that: - Takes an array of doubles as input - Prints the avearge of positive odd numbers in the array - Prints 'ERROR' for empty input array An Example: Input: [1.2,1.5,0.0,-2.3,3.5,7.1,-1.3] Output: 4.03333333 Thanks :)