Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- public class Metode {
- public static void main(String[] args) {
- DecimalFormat twoDecimals = new DecimalFormat("0.##");
- int totalWon = 3;
- int totalLost = 10;
- double totalRatio = (double) totalWon / totalLost;
- System.out.println(twoDecimals.format(totalRatio));
- // OUTPUT: 0,3 on windows -- 0.3 on mac
- // 0,3 stores as 0 in mysql, 0.3 stores as 0.3 in mysql
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement