*4.10(猜测生日)改写程序清单4-3,提示用户输入字符Y代表“是”,输入N代表“否”,代替之前输入1表示“是”和0表示“否”。
*4.10(Guess birthday)(Guess birthday) Rewrite Listing 4.3, GuessBirthday.java, to prompt the user to enter the character Y for Yes and N for No, rather than entering 1 for Yes and 0 for No.
下面是参考答案代码:
import java.util.*;
public class GuessBirthdayQuestion10 {
public static void main(String[] args) {
String set1 = " 1 3 5 7\n" + " 9 11 13 15\n" + "17 19 21 23\n" + "25 27 29 31";
String set2 = " 2 3 6 7\n" + "10 11 14 15\n" + "18 19 22 23\n" + "26 27 30 31";
String set3 = " 4 5 6 7\n" + "12 13 14 15\n" + "20 21 22 23\n" + "28 29 30 31";
String set4 = " 8 9 10 11\n"