0

What will be the code of this question?

During your math class, you are given a task to calculate the perimeter of a circle. You decide to write a small program that will take the radius as input, and will calculate and print the perimeter for you. The value for π (pi) is already defined. Sample Input 4 Sample Output 25.12

16th May 2021, 7:32 AM
Prathmesh Kumar
Prathmesh Kumar - avatar
8 odpowiedzi
+ 1
Hi! you've written a lot of your own code. re-write the program. your code should take three lines: 1. create a variable where the radius value will be taken. 2. create a second variable (perimeter). in this variable, write the correct formula for calculating the perimeter, where you will substitute the radius value. your first variable. 3. Display the perimeter variable on the screen. Do not print anything superfluous in your program! and do not display unnecessary messages on the screen! your program should be concise.
16th May 2021, 8:29 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
Thank u soo much.....
16th May 2021, 11:15 AM
Prathmesh Kumar
Prathmesh Kumar - avatar
0
Show us your code attempt
16th May 2021, 7:33 AM
Matias
Matias - avatar
0
you have to code the formula for the perimeter of a circle, please show us your attemps so we can help you out
16th May 2021, 7:34 AM
Apollo-Roboto
Apollo-Roboto - avatar
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double pi = 3.14; System.out.println("Please enter radius of circle:"); float radius = scanner.nextFloat(); double perimeter = perimeter(radius); System.out.println("Perimeter of Circle calculate by Java program is : " + perimeter); scanner.close(); } /* * @return perimeter of a circle. */ public static double perimeter(float radius){ return 2*Math.PI*radius; //your code goes here } }
16th May 2021, 7:35 AM
Prathmesh Kumar
Prathmesh Kumar - avatar
0
Ok let me try it
16th May 2021, 11:08 AM
Prathmesh Kumar
Prathmesh Kumar - avatar
0
all right, but just out of great respect for you, I'll allow it
16th May 2021, 11:10 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
Yes it worked
16th May 2021, 11:15 AM
Prathmesh Kumar
Prathmesh Kumar - avatar