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 ...
随机推荐
- linux服务器初步印象,远程连接mysql数据库,传输文件,启动/关闭tomcat命令
1.连接服务器数据库,以Navicat连接mysql为例 1.1 常规 新建连接,连接名,主机名或ip地址:127.0.0.1 端口:3306用户名:(服务器端)root密码:(服务器端)pwd 1. ...
- pthread_create()之前的属性设置
一.pthread_create()之前的属性设置1.线程属性设置我们用pthread_create函数创建一个线程,在这个线程中,我们使用默认参数,即将该函数的第二个参数设为NULL.的确,对大多数 ...
- Socat
http://www.oschina.net/p/socat/ tcpick https://sourceforge.net/projects/tcpick/
- POJ 1562 && ZOJ 1709 Oil Deposits(简单DFS)
题目链接 题意 : 问一个m×n的矩形中,有多少个pocket,如果两块油田相连(上下左右或者对角连着也算),就算一个pocket . 思路 : 写好8个方向搜就可以了,每次找的时候可以先把那个点直接 ...
- netstat命令查看服务器运行情况
netstat -n|grep 80出现大量time_wait 在运行netstat -n|grep 80 | awk '/^tcp/ {++S[$NF]} END {for(a in S) prin ...
- Android开发UI之开源项目第一篇——个性化控件(View)篇
原文:http://blog.csdn.net/java886o/article/details/24355907 本文为那些不错的Android开源项目第一篇——个性化控件(View)篇,主要介绍A ...
- poj 2996 Help Me with the Game(模拟)
题目:http://poj.org/problem?id=2996 题意:给出 棋盘 情况 输出 白棋 和 黑棋在 棋盘上的 白棋为大写字母 黑棋为小写字母 棋盘 左下点为原点(1,a) 输出 是 按 ...
- Innodb 锁系列1 同步机制
同步机制 Innodb实现了不依赖于平台的mutex,rwlock. 1. 全局变量 对于mutex, rwlock,都有一个全局链表. 1. mutex全局链表:mutex_list 2. rwlo ...
- ichartjs
ichartjs-基于html5的图表组件 不适合桌面端
- apache开源项目--TIKA
Tika是一个内容抽取的工具集合(a toolkit for text extracting).它集成了POI, Pdfbox 并且为文本抽取工作提供了一个统一的界面.其次,Tika也提供了便利的扩展 ...