📄 mod3ans.lst
字号:
listing 1
// Count spaces.
class Spaces {
public static void main(String args[])
throws java.io.IOException {
char ch;
int spaces = 0;
System.out.println("Enter a period to stop.");
do {
ch = (char) System.in.read();
if(ch == ' ') spaces++;
} while(ch != '.');
System.out.println("Spaces: " + spaces);
}
}
listing 2
// Change case.
class CaseChg {
public static void main(String args[])
throws java.io.IOException {
char ch;
int changes = 0;
System.out.println("Enter period to stop.");
do {
ch = (char) System.in.read();
if(ch >= 'a' & ch <= 'z') {
ch -= 32;
changes++;
System.out.println(ch);
}
else if(ch >= 'A' & ch <= 'Z') {
ch += 32;
changes++;
System.out.println(ch);
}
} while(ch != '.');
System.out.println("Case changes: " + changes);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -