HW3.17

import java.util.Scanner;
public class Solution
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print("scissor(0), rock(1), paper(2): ");
int playerValue = input.nextInt();
input.close();
int computerValue = (int)(Math.random() * 3);
String player = "";
if(playerValue == 0)
player = "scissor";
else if(playerValue == 1)
player = "rock";
else if(playerValue == 2)
player = "paper";
String computer = "";
if(computerValue == 0)
computer = "scissor";
else if(computerValue == 1)
computer = "rock";
else if(computerValue == 2)
computer = "paper";
if(playerValue == computerValue)
System.out.println("The computer is " + computer + ". You are " + player + " too. It is a draw.");
else
System.out.print("The computer is " + computer + ". You are " + player + ". ");
if(playerValue == 0 && computerValue == 1 || playerValue == 1 && computerValue == 2 ||
playerValue == 2 && computerValue == 0)
System.out.println("Computer win");
if(playerValue == 1 && computerValue == 0 || playerValue == 2 && computerValue == 1 ||
playerValue == 0 && computerValue == 2)
System.out.println("You win");
}
}
HW3.17的更多相关文章
- Golang, 以17个简短代码片段,切底弄懂 channel 基础
(原创出处为本博客:http://www.cnblogs.com/linguanh/) 前序: 因为打算自己搞个基于Golang的IM服务器,所以复习了下之前一直没怎么使用的协程.管道等高并发编程知识 ...
- .NET平台开源项目速览(17)FluentConsole让你的控制台酷起来
从该系列的第一篇文章 .NET平台开源项目速览(1)SharpConfig配置文件读写组件 开始,不知不觉已经到第17篇了.每一次我们都是介绍一个小巧甚至微不足道的.NET平台的开源软件,或者学习,或 ...
- Centos 6.6 下搭建php5.2.17+Zend Optimizer3.3.9+Jexus环境
(为何安装php5.2.17这个版本 因为phpweb这个程序用到了Zend Optimizer3.3.9 这个东东已经停止更新了 最高支持5.2版本的php 所以就有了一晚上填坑的自己和总结了这篇文 ...
- 企业IT管理员IE11升级指南【17】—— F12 开发者工具
企业IT管理员IE11升级指南 系列: [1]—— Internet Explorer 11增强保护模式 (EPM) 介绍 [2]—— Internet Explorer 11 对Adobe Flas ...
- CSharpGL(17)重构CSharpGL
CSharpGL(17)重构CSharpGL CSharpGL用起来我自己都觉得繁琐了,这是到了重构的时候. 下载 CSharpGL已在GitHub开源,欢迎对OpenGL有兴趣的同学加入(https ...
- ABP(现代ASP.NET样板开发框架)系列之17、ABP应用层——参数有效性验证
点这里进入ABP系列文章总目录 基于DDD的现代ASP.NET开发框架--ABP系列之17.ABP应用层——参数有效性验证 ABP是“ASP.NET Boilerplate Project (ASP. ...
- 从零开始编写自己的C#框架(17)——Web层后端首页
后端首页是管理员登陆后进入的第一个页面,主要是显示当前登陆用户信息.在线人数.菜单树列表.相关功能按键和系统介绍.让管理员能更方便的找到息想要的内容. 根据不同系统的需要,首页会显示不同的内容,比如显 ...
- ERROR 1010 (HY000): Error dropping database (can't rmdir './test/', errno: 17)
在删除数据库的时候报标题所示错误 mysql> drop database test; ERROR (HY000): Error dropping database (can't rmdir ' ...
- Xamarin for Visual Studio V3.11.431 于 2015.4.3-2015.4.17 最新发布(Win & Mac)
Beta Release: April 3 edited April 17 in Visual Studio Released versions: Windows Xamarin.VisualStud ...
随机推荐
- 简单的powershell 批量生成身份证复印件
用Powshell 脚本批量完成,代码比较简单,出生日期,图片我都没有改,图片用于测试,附件. cls; $path = Split-Path -Parent $MyInvocation.MyComm ...
- MVC-Model数据注解(一)-系统(DataAnnotations)
要使用验证,首先,web.config要开户验证: <appSettings> <add key="ClientValidationEnabled" value= ...
- CODEVS 1004四子连棋
[题目描述 Description] 在一个4*4的棋盘上摆放了14颗棋子,其中有7颗白色棋子,7颗黑色棋子,有两个空白地带,任何一颗黑白棋子都可以向上下左右四个方向移动到相邻的空格,这叫行棋一步,黑 ...
- 视频边下边播--缓存播放数据流-b
google搜索“iOS视频变下边播”,有好几篇博客写到了实现方法,其实只有一篇,其他都是copy的,不过他们都是使用的本地代理服务器的方式. 原理很简单,但是缺点也很明显,需要自己写一个本地代理服务 ...
- winform 项目获取app.config 中appSettings节点数据
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSe ...
- loadmore & scroll
loadmore <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.m ...
- percona-xtrabackup安装及使用教程
安装percona-xtrabackup依赖包(前提已安装mysql) yum -y install perl-CPAN perl-DBD-MySQL perl make gcc gcc-c++ pa ...
- 132. Palindrome Partitioning II
题目: Given a string s, partition s such that every substring of the partition is a palindrome. Return ...
- file_operations结构2
对与应用层的每个系统调用,驱动程序都有一个与之对应的函数.对于字符设备驱动程序,这些函数集合在一个file_operations类型的数据结构中,该结构体在Linux内核的include/linux/ ...
- 【POJ】1505 Copying Books
此题主要采用DP思路,难点是求解"/",需要考虑划分数量不够的情况,先采用DP求解最优解,然后采用贪心求解slash.防止中间结果出错,使用了unsigned int. #incl ...