SHARE
TWEET

Untitled

a guest Aug 13th, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.text.DecimalFormat;
  2.  
  3. public class Metode {
  4.  
  5.     public static void main(String[] args) {
  6.         DecimalFormat twoDecimals = new DecimalFormat("0.##");
  7.         int totalWon = 3;
  8.         int totalLost = 10;
  9.         double totalRatio = (double) totalWon / totalLost;
  10.         System.out.println(twoDecimals.format(totalRatio));
  11.        
  12.         // OUTPUT: 0,3 on windows -- 0.3 on mac
  13.        
  14.         // 0,3 stores as 0 in mysql, 0.3 stores as 0.3 in mysql
  15.     }
  16.    
  17. }
RAW Paste Data
Top