Java中控制台输出的内容如何转到对话框中,System.out.printf()中的内容怎样写才
2个回答
展开全部
import javax.swing.JOptionPane;
public class p117_4_5_1 {
public static void main(String[] args) {
int a = 1;
int b = 20;
StringBuilder builder = new StringBuilder(String.format(
"%12s%12s%12s%12s\n", "千克", "磅", "磅", "千克"));
for (int i = 1; i <= 10; a += 2, b += 12, i++) {
builder.append(String.format("%12d%12.1f%12d%12.2f\n", a, a * 2.2, b,
b / 2.2));
}
JOptionPane.showMessageDialog(null, "" + builder.toString());
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询