04-27-2011, 06:30 AM
You can use DecimalFormat to format the out put of numbers
package testproject;
import java.text.DecimalFormat;
public class Main {
public static void main(String[] args) {
double numberToRound = 12345.6789;
DecimalFormat df = new DecimalFormat("0");
System.out.println("Rounded number = " + df.format(numberToRound));
}
}
The output will be as
Rounded number = 12345
Let me know if you are unable to solve the problem with this.
package testproject;
import java.text.DecimalFormat;
public class Main {
public static void main(String[] args) {
double numberToRound = 12345.6789;
DecimalFormat df = new DecimalFormat("0");
System.out.println("Rounded number = " + df.format(numberToRound));
}
}
The output will be as
Rounded number = 12345
Let me know if you are unable to solve the problem with this.
0300-9520262
Get solution in 24 hour |cpmputer & internet
mileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
