Skip to content

Instantly share code, notes, and snippets.

@codewithcats
Created April 17, 2012 23:02
Show Gist options
  • Save codewithcats/2409720 to your computer and use it in GitHub Desktop.
Save codewithcats/2409720 to your computer and use it in GitHub Desktop.
Calculate Unit Per Day - Team 6
public int calUnit() {
BigDecimal power = new BigDecimal(this.power);
BigDecimal duration = new BigDecimal(this.duration);
BigDecimal result = power.divide(new BigDecimal("1000.00")).multiply(duration);
String ans = result.setScale(0,BigDecimal.ROUND_UP).toString();
return Integer.parseInt(ans);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment