fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.text.*;
  4.  
  5. class Main
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. double d = 50.12345;
  10. DecimalFormat df = new DecimalFormat("#.##");
  11. System.out.println(df.format(d));
  12.  
  13. d = 50.0;
  14. df = new DecimalFormat("#.##");
  15. System.out.println(df.format(d));
  16.  
  17. d = (double) (1*1.000/Integer.parseInt(2+"")/1.000*100);
  18. df = new DecimalFormat("#.##");
  19. System.out.print(df.format(d));
  20.  
  21. }
  22. }
Success #stdin #stdout 0.09s 380672KB
stdin
Standard input is empty
stdout
50.12
50
50