Pictures order goes: Sample output, code 1, code 2, tester code, my output. 3 If
ID: 3726368 • Letter: P
Question
Pictures order goes: Sample output, code 1, code 2, tester code, my output.3 If your Point and Circle classes are defined properly, the tester pr 65 66 67 Radius: 2.00 Center [0.00, 0.00] Perimeter: 12.57 Area: 12.57 68 Radius: 10.00 Center-1.00, -10.00] Perimeter: 62.83 Area: 314.16 69 Radius: 1.00 Center [2.00, -1.001 Perimeter: 6.28 Area: 3.14 70 Radius: 1.00 Center [-1.00, -10.00] Perimeter: 6.28 Area: 3.14 71 Radius:25.00 Center [0.00, To.00] Perimeter: 157.08 Area: 1963.50 2 Radius: 1.00 Center[0.00, d.00] Perimeter: 6.28 Area: 3.14 3 74 75 76
Explanation / Answer
import java.text.DecimalFormat; //header file for decimalformat
public static void main(String args[]){
DecimalFormat df = new DecimalFormat("#.##"); //this is used to round decimal places to 2
System.out.println(df.format(c1)); //if we print using decimal format then decimal places will remain 2
c2.setRadius(1); //if you set radius as 0, then obviously the result will be 0, you should set it as 1 to get the desired output
}
//"c2.setRadius(0);" should be replaced with "c2.setRadius(1);"