Java第三章习题3-3(彩票中奖2)
来源:互联网 发布:原生js获取json文件 编辑:程序博客网 时间:2024/04/30 08:41
LotteryNumber.java
/* * To change this template, choose Tools | Templates * and open the template in the editor. *//** * * @author Administrator */public class LotteryNumber { public void giveMess(int number){ if(number/10000>=10 || number/10000<1){ System.out.println("please input a five digit number:"); } else{ int num1=number%10; int num2=number%100; int num3=number%1000; int count = 0 ; //用来记录前面是否得奖,避免重复 if(num3==875||num3==326||num3==596){ System.out.println("Congratulations you won the first place ."); count=count+1; } else if(num2==29 || num2==46 ||num2==21){ System.out.println("Congratulations you won the second place ."); count=count+1; } else if(num1==1 || num1==3 ||num1==9){ System.out.println("Congratulations you won the third place ."); } else { System.out.println("It's a pity that you didn't win the prize. "); } } } }
Test.java
import java.util.Scanner;/* * To change this template, choose Tools | Templates * and open the template in the editor. *//** * * @author Administrator */public class Test { public static void main(String[] args){ Scanner reader=new Scanner(System.in); System.out.println("please input your number:"); int number=reader.nextInt(); LotteryNumber lo=new LotteryNumber(); lo.giveMess(number); } }
0 0
- Java第三章习题3-3(彩票中奖2)
- Java第三章42页例3-2(彩票中奖1)
- 第三章习题3-第三题=改写彩票例题
- 课本例题3-2==彩票中奖
- 彩票中奖
- 彩票中奖器 (递归运用)
- Java第三章习题3-6(完数)
- c++primer 第三章习题(3)
- 选出彩票中奖用户
- 彩票中奖几率
- 《APUE》第三章笔记(4)及习题3-2
- 刷紫书第三章习题(习题3-1到习题3-6)
- 刷紫书第三章习题(习题3-7到习题3-12)
- Java第三章习题3-4(for循环输出俄文字母表)
- Java第三章习题3-5(1到20的阶乘和)
- Java第三章习题3-7(1到n的阶乘和<=9999)
- 彩票中奖,心情不错,呵呵
- 简单的彩票中奖程序
- CorelDRAW中的轮廓图工具该怎么进行使用
- 阿里无线技术架构演进
- 四种启动模式
- 第一个SpringMVC+Hibernate框架搭建之路
- ubuntu15.10 配置wildfly10 服务器
- Java第三章习题3-3(彩票中奖2)
- c++ STL 数据结构底层结构
- 正则表达式学习及应用
- Finished with Non Zero Exit Value 3
- 如何使用红杏的公益代理
- 跟我一起学OC系列-布尔类型
- js验证上传的文件是否为JPEG,PNG,JPG,GIF格式
- 对于无线传感网的初步认识
- AutoCAD套合(叠加)卫星影像和矢量路网数据-CAD配准