public class Solution
 {
     public static void main(String[] args)
     {
         int n1 = (int)(Math.random() * 5 + 1);
         int n2 = (int)(Math.random() * 5 + 1);

         diceGame(n1, n2);
     }

     public static void diceGame(int n1, int n2)
     {
         if(n1 + n2 == 2 || n1 + n2 == 3 || n1 + n2 == 12)
         {
             System.out.println("You rolled " + n1 + " + " + n2 + " = " + (n1 + n2));
             System.out.println("You win");
         }
         else if(n1 + n2 == 7 || n1 + n2 == 11)
         {
             System.out.println("You rolled " + n1 + " + " + n2 + " = " + (n1 + n2));
             System.out.println("You lose");
         }
         else
         {
             int sum = n1 + n2;
             System.out.println("You rolled " + n1 + " + " + n2 + " = " + (n1 + n2));
             System.out.println("The point is " + (n1 + n2));

             int num1;
             int num2;

             while(true)
             {
                 num1 = (int)(Math.random() * 5 + 1);
                 num2 = (int)(Math.random() * 5 + 1);

                 System.out.println("You rolled " + num1 + " + " + num2 + " = " + (num1 + num2));
                 if(num1 + num2 == 7)
                 {
                     System.out.println("You lose");
                     break;
                 }

                 else if(num1 + num2 == sum)
                 {
                     System.out.println("You win");
                     break;
                 }

                 sum = num1 + num2;
             }
         }
     }
 }

HW5.29的更多相关文章

  1. IIC驱动移植在linux3.14.78上的实现和在linux2.6.29上实现对比(deep dive)

    首先说明下为什么写这篇文章,网上有许多博客也是介绍I2C驱动在linux上移植的实现,但是笔者认为他们相当一部分没有分清所写的驱动时的驱动模型,是基于device tree, 还是基于传统的Platf ...

  2. CSharpGL(29)初步封装Texture和Framebuffer

    +BIT祝威+悄悄在此留下版了个权的信息说: CSharpGL(29)初步封装Texture和Framebuffer +BIT祝威+悄悄在此留下版了个权的信息说: Texture和Framebuffe ...

  3. DM9000驱动移植在mini2440(linux2.6.29)和FS4412(linux3.14.78)上的实现(deep dive)篇一

    关于dm9000的驱动移植分为两篇,第一篇在mini2440上实现,基于linux2.6.29,也成功在在6410上移植了一遍,和2440非常类似,第二篇在fs4412(Cortex A9)上实现,基 ...

  4. 【hihoCoder】1148:2月29日

    问题:http://hihocoder.com/problemset/problem/1148 给定两个日期,计算这两个日期之间有多少个2月29日(包括起始日期). 思路: 1. 将问题转换成求两个日 ...

  5. 《Entity Framework 6 Recipes》中文翻译系列 (29) ------ 第五章 加载实体和导航属性之过滤预先加载的实体集合和修改外键关联

    翻译的初衷以及为什么选择<Entity Framework 6 Recipes>来学习,请看本系列开篇 5-13  过滤预先加载的实体集合 问题 你想过滤预先加载的实体集合,另外,你想使用 ...

  6. 背水一战 Windows 10 (29) - 控件(文本类): RichTextBlock, RichTextBlockOverflow, RichEditBox

    [源码下载] 背水一战 Windows 10 (29) - 控件(文本类): RichTextBlock, RichTextBlockOverflow, RichEditBox 作者:webabcd ...

  7. 搭建 Windows Server 2003 + IIS6.0 + FastCGI + PHP5.3.29 + MySQL5.5.38 + Memcached1.2.6

    一.下载相关软件: 1.VC9运行库 即VISUAL C++ 2008 自PHP5.3.0开始,PHP提供VC2008编译版,需要安装VC++ 2008的运行库. [微软官方下载] http://ww ...

  8. 将形如:Oct 8, 2016 5:29:44 PM串转换成正常时间在真机上遇到的坑

    将形如:Oct 8, 2016 5:29:44 PM串转换成正常时间在真机上遇到的坑 /** * 根据传入字符串 * * @param str 传入的日期字符串 形如:Oct 8, 2016 5:29 ...

  9. proxifier 3.29 key

    Proxifier 3.29 serial key :-   [Use only One ]  (Standard Edition Keys) 5EZ8G-C3WL5-B56YG-SCXM9-6QZA ...

随机推荐

  1. DLL远程注入与卸载

    以下提供两个函数,分别用于向其它进程注入和卸载指定DLL模块.支持Unicode编码. #include <windows.h>#include <tchar.h>#inclu ...

  2. asp防注入安全问题

    一.古老的绕验证漏洞虽然古老,依然存在于很多小程序之中,比如一些企业网站的后台,简单谈谈.这个漏洞出现在没有对接受的变量进行过滤,带入数据库判断查询时,造成SQL语句的逻辑问题.例如以下代码存在问题: ...

  3. 对jQuery.isArray方法的分析

    jQuery.isArray方法应于判断是不是数组,是的话返回true,否则返回false.调用如:jQuery.isArray([]),返回true.其实现源码如下: isArray: Array. ...

  4. 使用 Spark 进行微服务的实时性能分析

    [编者按]当开发者从微服务架构获得敏捷时,观测整个系统的运行情况成为最大的痛点.在本文,IBM Research 展示了如何用 Spark 对微服务性能进行分析和统计,由 OneAPM 工程师编译整理 ...

  5. APK签名校验绕过

    APK签名校验绕过 Android JNI 获取应用签名 android apk 防止反编译技术第一篇-加壳技术 android apk 防止反编译技术第五篇-完整性校验 利用IDA Pro反汇编程序 ...

  6. java List 去重(两种方式)

    方法一: 通过Iterator 的remove方法 Java代码  public void testList() { List<Integer> list=new ArrayList< ...

  7. php用于URL的base64

    function base64url_encode($plainText) { $base64 = base64_encode($plainText); $base64url = strtr($bas ...

  8. Android安全问题 抢先接收广播 - 内因篇之广播发送流程

    导读:本文说明系统发送广播的部分流程,如何利用Intent查找到对应接收器.我们依然只关注接收器的排序问题 这篇文章主要是针对我前两篇文章 android安全问题(四) 抢先开机启动 - 结果篇 an ...

  9. MySQL 普通索引、唯一索引和主索引

    1.普通索引 普通索引(由关键字KEY或INDEX定义的索引)的唯一任务是加快对数据的访问速度.因此,应该只为那些最经常出现在查询条件(WHEREcolumn=)或排序条件(ORDERBYcolumn ...

  10. 基于Android Studio搭建hello world工程

    基于Android Studio搭建hello world工程 版本:ANDROID STUDIO V0.4.6 This download includes: ·        Android St ...