HW3.17
2024-10-18 04:24:05
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"); } }
最新文章
- [转]关于typedef的用法总结
- C# Retry重试操作解决方案(附源码)
- Hibernate getCurrentSession()和openSession()的区别
- 4.1 spring-alias 标签的解析;
- python:UnicodeEncodeError
- VS2008试用版到期解决办法
- document.readystate
- 【HDU1856】More is better(并查集基础题)
- 【Spring源码分析】AOP源码解析(下篇)
- java list 去重
- django中的中间件机制和执行顺序
- Linux中Nginx安装与配置详解
- Java方法containsAll学习
- thinkphp5开发的网站出现”No input file specified”(php版本5.6.27)
- Google Chrome调试js代码,开发者工具之调试工具常用功能
- linux系统cpu使用100%的命令
- css实现栅格的方法
- JVM致命错误日志(hs_err_pid.log)解读
- 洛谷P2775 机器人路径规划问题
- 搭建配置cacti,采集信息监控