Java第三章42页例3-2(彩票中奖1)
2016-09-13 11:29
507 查看
Administrator.java
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 the number:");
int number = reader.nextInt();
Administrator person=new Administrator();
person.giveMess(number);
}
}
Administrator.java
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author Administrator */ public class Administrator { public void giveMess(int number){ if(number/10000<=0 ||number/10000>=10){ System.out.println("please input fifth numbers"); } else{ int num1=number%10; int num2=number%100; int num3=number%1000; switch(num1){ case 1: case 3: case 9:System.out.println("three!!!!"); break; default:System.out.println("no have three!!!!"); } switch(num2){ case 29: case 46: case 21:System.out.println("two!!!!"); break; default:System.out.println("no have two!!!!"); } switch(num3){ case 875: case 326: case 596:System.out.println("one!!!!"); break; default:System.out.println("no have one!!!!"); } } } }
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 the number:");
int number = reader.nextInt();
Administrator person=new Administrator();
person.giveMess(number);
}
}
相关文章推荐
- Struts2配置web.xml
- Spring IoC学习笔记(一)
- 五,Java集合类(3)——List接口及其实现类
- Java第三章40页例3-1(对整数排序)
- java调.NET webapi时间戳报错问题
- Java 实现 堆排序 快速排序 以及 TopK问题(一)
- JavaSE 异常
- Spring boot读取配置文件
- 4种方法让SpringMVC接收多个对象
- 性能分析工具之-- Eclipse Memory Analyzer tool(MAT)(二)
- java垃圾回收机制
- Java多线程学习
- java Collection集合删除某一元素方法汇总
- java关键字的适用总结
- java基础03
- eclipse如何调试system_server
- Struts2入门-Hello Word实例
- eclipse下maven web项目的创建
- 在ECLIPSE中开发CASSANDRA
- [解决]java.io.IOException: Cannot obtain block length for LocatedBlock