HW5.29


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的更多相关文章
- IIC驱动移植在linux3.14.78上的实现和在linux2.6.29上实现对比(deep dive)
首先说明下为什么写这篇文章,网上有许多博客也是介绍I2C驱动在linux上移植的实现,但是笔者认为他们相当一部分没有分清所写的驱动时的驱动模型,是基于device tree, 还是基于传统的Platf ...
- CSharpGL(29)初步封装Texture和Framebuffer
+BIT祝威+悄悄在此留下版了个权的信息说: CSharpGL(29)初步封装Texture和Framebuffer +BIT祝威+悄悄在此留下版了个权的信息说: Texture和Framebuffe ...
- DM9000驱动移植在mini2440(linux2.6.29)和FS4412(linux3.14.78)上的实现(deep dive)篇一
关于dm9000的驱动移植分为两篇,第一篇在mini2440上实现,基于linux2.6.29,也成功在在6410上移植了一遍,和2440非常类似,第二篇在fs4412(Cortex A9)上实现,基 ...
- 【hihoCoder】1148:2月29日
问题:http://hihocoder.com/problemset/problem/1148 给定两个日期,计算这两个日期之间有多少个2月29日(包括起始日期). 思路: 1. 将问题转换成求两个日 ...
- 《Entity Framework 6 Recipes》中文翻译系列 (29) ------ 第五章 加载实体和导航属性之过滤预先加载的实体集合和修改外键关联
翻译的初衷以及为什么选择<Entity Framework 6 Recipes>来学习,请看本系列开篇 5-13 过滤预先加载的实体集合 问题 你想过滤预先加载的实体集合,另外,你想使用 ...
- 背水一战 Windows 10 (29) - 控件(文本类): RichTextBlock, RichTextBlockOverflow, RichEditBox
[源码下载] 背水一战 Windows 10 (29) - 控件(文本类): RichTextBlock, RichTextBlockOverflow, RichEditBox 作者:webabcd ...
- 搭建 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 ...
- 将形如:Oct 8, 2016 5:29:44 PM串转换成正常时间在真机上遇到的坑
将形如:Oct 8, 2016 5:29:44 PM串转换成正常时间在真机上遇到的坑 /** * 根据传入字符串 * * @param str 传入的日期字符串 形如:Oct 8, 2016 5:29 ...
- proxifier 3.29 key
Proxifier 3.29 serial key :- [Use only One ] (Standard Edition Keys) 5EZ8G-C3WL5-B56YG-SCXM9-6QZA ...
随机推荐
- ASC #1
开始套题训练,第一套ASC题目,记住不放过每一题,多独立思考. Problem A ZOJ 2313 Chinese Girls' Amusement 循环节 题意:给定n,为圆环长度,求k < ...
- winform学习日志(十九)----------真正三层架构之登录
摘要:一:三层构架的基础知识在项目开发的过程中,有时把整个项目分为三层架构,其中包括:表示层(UI).业务逻辑层(BLL)和数据访问层(DAL).三层的作用分别如下: 表示层:为用户提供交互操作界面, ...
- sizeof运算符来获取各种数据类型在内存中所占字节数--gyy整理
C++并没有规定各种数据类型在内存中的存储大小,依赖于不同的编译器的不同而不同,要想获知当前编译器对各种数据类型分配的大小,可以通过sizeof运算符来获取. 使用方法1: sizeof(数据类型) ...
- SPRING IN ACTION 第4版笔记-第九章Securing web applications-005-Applying LDAP-backed authentication
一. 1.This method is the LDAP analog to jdbcAuthentication() @Override protected void configure(Aut ...
- WCF之各种WCF引用方式
写在开头:本文内容来自 WCF全面解析中的一个经典例子,如果你已经看过了,那么可以忽略本文,本文旨在和大家分享不一样的WCF使用方法. 准备工作: 1.创建解决方案WCFService(当然名字可以任 ...
- 213. House Robber II
题目: Note: This is an extension of House Robber. After robbing those houses on that street, the thief ...
- P51、面试题5:从尾到头打印链表
题目:输入一个链表的头结点,从尾到头反过来打印出每个结点的值. 链表结点定义如下: Struct ListNode{ int m_nKey; ListNode* m_pNext; }; 我们可 ...
- Java对象相关元素的初始化过程
1.类的成员变量.构造函数.成员方法的初始化过程 当一个类使用new关键字来创建新的对象的时候,比如Person per = new Person();JVM根据Person()寻找匹配的类,然后找到 ...
- UNIX内核的文件数据结构 -- v 节点与 i 节点
龙泉居士:http://hi.baidu.com/zeyu203/item/cc89cfc0f36bfecc994aa07c 内核使用三种数据结构表示打开的文件(如图),他们之间的关系决定了在文件共享 ...
- node.js模块之util模块
util提供了各种使用的工具.require('util') to access them. Util.format(format,[..]) Returns a formatted string u ...