. To accept radius of a circle, calculate area and print the result
in the following format: Radius is
Area is
Repeat the whole process n times. java
Answers
Answered by
1
import java.util.Scanner;
public class Area {
public static void main(String[ ] args) {
Scanner sc = new Scanner(System.in);
// Accepting number of iterations.
System.out.print("Enter number of iterations - ");
int iterations = sc.nextInt( );
for (int i = 0; i < iterations; i++) {
// Accepting Radius.
System.out.print("Enter Radius - ");
float radius = sc.nextFloat( );
// Printing Radius and Area.
System.out.printf("Radius - %f%n Area - %f%n", radius, Math.PI * radius * radius);
}
}
}
Similar questions