Assignment:write a program to compute the shaded portion of a circle in java, provided that the value of the outer circle = 25cm, and the inner circle=15cm
public class Q163333 {
/**
* The start point of the program
* @param args
*/
public static void main(String[] args) {
//the outer circle = 25cm
final double r1= 25;
//the inner circle=15cm
final double r2= 15;
//Calculate area 1
double area1=Math.PI*r1*r1;
//Calculate area 2
double area2=Math.PI*r2*r2;
//Calculate the area shaded portion of a circle
double area3=area1-area2;
//Display result
System.out.println("The shaded portion of a circle: "+String.format("%.2f", area3));
}
}
Comments
Leave a comment