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. leetcode3 Two Sum III – Data structure design

    Question: Design and implement a TwoSum class. It should support the following operations: add and f ...

  2. jquery 请求jsp传递json数据的方法

    $(function() { $("a[name=hrefID]").click(function() { var id = $(this).attr("id" ...

  3. python List&Set&Dict交集、并集、差集

    1.python List交集.并集.差集 1). 获取两个list 的交集#方法一: a=[2,3,4,5] b=[2,5,8] tmp = [val for val in a if val in  ...

  4. java内存模型 年轻代/年老代 持久区

    jvm中的年轻代 老年代 持久代 gc   虚拟机中的共划分为三个代:年轻代(Young Generation).老年代(Old Generation)和持久代(Permanent Generatio ...

  5. 组策略限制添加用户作为服务登录导致ITAtomcat服务无法启动(log on as a service)

    [故障类型]:ITA tomcat服务器无法启动. [关 键 词]:Logon as a service  作为服务登录  tomcat  loggeter [适用版本]:FusionCloud So ...

  6. Delphi里的RTTI与反射(举例换掉FOnChange)

    Delphi2010之后的RTTI做了很大休整,现在用起来很爽了哦.甚至可以获取某些类的内部私有单元,然后为其赋值!讲这个RTTI增强的,可以参考网上的多个博客内容,我列举一下:Delphi2010R ...

  7. Spring与Struts2整合

    Spring与Struts2为什么要整合呢? 把Action实例交给Spring来管理!! 1.单独测试Struts是否添加成功(jar包和配置文件),先单独测试,不要整合之后再测试,容易出问题 we ...

  8. Android 自定义对话框使用静态Handler传递参数

    JsdMainDialog.java package com.jsd.demo; import android.app.Activity; import android.content.Context ...

  9. Win7安装错误提示与解决办法大全

    Windows7安装时有许多提示错误,许多朋友不知道如何解决,那就看看这篇软媒整理的文章吧,或许有些帮助.本文出现的问题同样应用于其他版本的Windows 7,甚至是Vista,收藏一下本文,或者某天 ...

  10. Innodb MVCC源码实现

    1. 概述 MVCC: 即多版本一致性,在事务模型下,使用version控制数据版本,关系型数据库基本都实现了MVCC,以对表数据的读写互不阻塞,增大了并发量. Oracle和MySQL数据库都是使用 ...