请给一个Java中测试类format的源程序或应用程序或测试成功的图片

来源:百度知道 编辑:UC知道 时间:2024/05/26 21:01:40
只是关于这一个类的实例
1、分析指定的Java类,用文字或图表说明其作用、大概的构建思想、用到了什么主要的相关类和接口、其父类和子类等。
2、编写一个程序测试此类,验证其功能。
3、文档:
(1)你分析的Java类源码
(2)你编写的测试此类的程序源码
(3)类的分析报告,以及你的测试程序运行结果和结论。

import java.text.*;

public class DecimalFormatDemo
{

public static void main(String[] x)
{
DecimalFormat twoDigitsPastPoint = new DecimalFormat("0.00");
DecimalFormat threeDigitsPastPoint = new DecimalFormat("00.000");

double d = 12.3456789;
System.out.println(twoDigitsPastPoint.format(d));
System.out.println(threeDigitsPastPoint.format(d));

double money = 12.8;
System.out.println("$" + twoDigitsPastPoint.format(money));
String numberString = twoDigitsPastPoint.format(money);
System.out.println(numberString);

DecimalFormat percent = new DecimalFormat("0.00%");

double fraction = 0.734;
System.out.println(percent.format(fraction));

DecimalFormat eNotation1 =
new DecimalFormat("#0.###E0&quo