Created
September 17, 2015 01:28
-
-
Save srigalamilitan/be48e52f17f4b1fa755d to your computer and use it in GitHub Desktop.
Pembulatan 1000
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.math.RoundingMode; | |
import java.math.BigDecimal; | |
public class Pembulatan | |
{ | |
public static int pembulatan1000( int nilai ){ | |
BigDecimal _value = new BigDecimal( (double)nilai/1000); | |
_value= _value.setScale(0,RoundingMode.UP); | |
return _value.intValue()*1000; | |
} | |
public static void main(String []args){ | |
int value = 1235; | |
System.out.println("Nilai Awal : "+value+" Menjadi : "+pembulatan1000(value)); | |
int value2 = 900; | |
System.out.println("Nilai Awal : "+value2+" Menjadi : "+pembulatan1000(value2)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment