mistake2.java
来自「Java 入门书的源码」· Java 代码 · 共 19 行
JAVA
19 行
/* Adds a println statement in the body of
* the while loop of Example 3.8
*/
import iopack.Io;
public class Mistake2 {
public static void main(String [] args) {
int sum = 0;
int count = 1;
int high = Io.readInt("Enter the number of squares to sum");
while (count <= high) {
sum += count*count;
System.out.println("Sum is " + sum);
}
System.out.println("The sum of the first " + high +
" squares is " +sum);
Io.readString("Press any key to exit"); // Added for IDE use
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?