Answer:
Following is the code in Java Language :
DecimalFormat form1= new DecimalFormat ("0.####");  // create an instance of                                               .                                               //DecimalFormat
System.out.println (form1.format(res)); // display the value in proper format
Explanation:
Following are the description of the program