您的位置:首页 > 编程语言 > Java开发

Java第三章42页例3-2(彩票中奖1)

2016-09-13 11:29 507 查看

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);
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: