testdowhile.java

来自「很好的程序欢迎大家来下载。初学者很有用的。」· Java 代码 · 共 25 行

JAVA
25
字号
import javax.swing.JOptionPane;public class TestDoWhile {  /** Main method */  public static void main(String[] args) {    int data;    int sum = 0;    // Keep reading data until the input is 0    do {      // Read the next data      String dataString = JOptionPane.showInputDialog(null,        "Enter an int value, \nthe program exits if the input is 0",        "TestDo", JOptionPane.QUESTION_MESSAGE);      data = Integer.parseInt(dataString);      sum += data;    } while (data != 0);    JOptionPane.showMessageDialog(null, "The sum is " + sum,      "TestDo", JOptionPane.INFORMATION_MESSAGE);  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?