猜生日
2015-08-19 00:05
495 查看
import java.util.Scanner; public class GuessBirthday { public static void main(String [] args) { String set1 = "1 3 5 7\n" + "9 11 13 15\n" + "17 19 21 23\n" + "25 17 29 31\n"; String set2 = "2 3 6 7\n" + "10 11 13 15\n" + "18 19 20 21\n"+ "26 27 30 31\n"; String set4 = "8 9 10 11\n" + "12 13 14 15\n" + "16 17 18 19\n" + "20 21 22 23\n"; String set5 = "16 17 18 19\n" + "20 21 22 23\n" + "24 25 26 27\n" + "28 29 30 31\n"; String set3 = "4 5 6 7\n" + "12 13 14 15\n" + "20 21 22 23\n" + "28 29 30 31\n"; int day=0; Scanner input = new Scanner(System.in); System.out.print("Is your birthday in Set1?"); System.out.print(set1); System.out.print("\nEnter 0 for No and 1 for Yes: "); int answer = input.nextInt(); if(answer == 1) day += 1; System.out.print("\nIs your birthday in Set2?"); System.out.print(set2); System.out.print("\nEnter 0 for No and 1 for Yes: "); answer = input.nextInt(); if(answer == 1) day += 2; System.out.print("\nIs your birthday in Set3?"); System.out.print(set3); System.out.print("\nEnter 0 for No and 1 for Yes: "); answer = input.nextInt(); if(answer == 1) day += 4; System.out.print("\nIs your birthday in Set4?"); System.out.print(set4); System.out.print("\nEnter 0 for No and 1 for Yes: "); answer = input.nextInt(); if(answer == 1) day += 8; System.out.print("\nIs your birthday in Set5?"); System.out.print(set5); System.out.print("\nEnter 0 for No and 1 for Yes: "); answer = input.nextInt(); if(answer == 1) day += 16; input.close(); System.out.println("\nYour birthday is " + day + "!"); } }
相关文章推荐
- c++打印心形
- pat(A) 07-排序1. 排序(水题)
- sqlalchemy(一)基本操作
- linux gpio 控制 基于 sysfs
- 生活的哲学:高尔夫球和啤酒
- Mysql索引
- UI基本控件
- IIS处理浏览器请求的流程 | 应用程序的生命周期
- 希尔排序
- 每 172 个活动 RSA 证书中就有一个容易受到攻击
- 使用 rsync 复制大文件的一些误解
- 在 Fedora 上使用 Steam play 和 Proton 来玩 Windows 游戏
- Java对日期Date类进行加减运算、年份加减月份加减、时间差等等
- Python中字典的基础知识归纳小结
- 详解Python中映射类型(字典)操作符的概念和使用
- 详解Python中映射类型的内建函数和工厂函数
- 深入理解Python中字典的键的使用
- Python中的集合类型知识讲解
- 深入解析Python中的集合类型操作符
- Python中集合的内建函数和内建方法学习教程