测试出生日期的小程序

猜出生日期

只有月份哦

代码如下:

package Day05; import java.util.Arrays;
import java.util.Scanner; public class GuessBirthdayDate {
public static void main(String[] args) {
int[][] possibleDateArr = {
{1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31},
{2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31},
{4,5,6,7,12,13,14,15,20,21,22,23,28,29,30,31},
{8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31},
{16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}
};
Scanner sc = new Scanner(System.in);
int birthDate = 0;
for (int i = 0; i < possibleDateArr.length; i++) {
System.out.println("你的生日的日期(1-31)在下面的数组中吗?1=是,0=否:");
System.out.println(Arrays.toString(possibleDateArr[i]));
birthDate += sc.nextInt() * possibleDateArr[i][0];
}
sc.close();
System.out.println("你的出生日期是" + birthDate + "号");
}
}

posted @ 2017-06-20 18:44  辰峰  阅读(613)  评论(0编辑  收藏  举报