476179

Untitled

Nov 12th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. System.out.println("Example 1: Precision");
  2.  
  3. double temp = 78.42819;
  4. System.out.printf("The temperature is %.2f degrees",temp);
  5.  
  6.  
  7.  
  8. System.out.println("Example2 : Precision");
  9.  
  10. double value1 = 123.45678, value2 = 123.45678, value3 = 123.45678;
  11. System.out.printf("%.1f %.2f %.3f\n",value1, value2, value3);
  12. //% - format specifier
  13. //._ - precision
  14. //f - value
Add Comment
Please, Sign In to add comment