# java code correction

Q:

1.Complete the following Java program to, using **BigDecimal**, calculate the radius of the circle whose diameter is stored in the variable *diameter*. The radius is calculated as half the diameter. For example, if diameter is 4, the radius is 2, and if diameter* *is 11.5, the radius is 5.75. Create a NetBeans project called Q1 and copy the code in the box below into your project. Implement and test your code and verify that the program generates the following output**: (10 points)**

Radius= 5.75

package q1; import java.math.BigDecimal; public class Q1 { public static void main(String[] args) { float diameter=11.5f; } } |

my answer :

package q1;

import java.math.BigDecimal;

public class Q1 {

public static void main(String[] args) {

float diameter=11.5f;

BigDeciamal diameter=radius.multiply(half);

BigDecimal half= new BigDecimal(1/2);

BigDecimal radius = new BigDecimal ( 5.75 );

System.out.println(“The radius is “+radius);

}

}