栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

手机尾号判断是否吉利 Java

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

手机尾号判断是否吉利 Java

package Demo01;
import java.util.Scanner;
public class SelDemo {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你的号码:");
        String strSel = sc.next();
        GetLast4 r4 = new GetLast4();
        if(!r4.notRightSel(strSel)){
            System.out.println("输入的位数有误!");
        }else{
            if(r4.notInlandSel(strSel)){
                System.out.println("非大陆手机号!");
            }else{
                if(r4.isDianxin(strSel)){
                    System.out.println("电信号码!");
                }
                int lastfour = r4.Last4(strSel);
                int cal = r4.calculater(lastfour);
                String resule = r4.cTiao(cal);
                System.out.println(resule);
            }
        }
    }
}
package Demo01;

public class GetLast4 {
    public int Last4(String strSel){
        strSel=strSel.substring(7,11);//截取后4位
        int intSel = Integer.parseInt(strSel);//转为interesting
        return intSel;
    }
    public int calculater(int lastfour){
        lastfour = lastfour%80;//对结果进行计算
        return lastfour;
    }
    public String cTiao(int lastfour){
        String arr[] = {"吉","不吉利","非常吉利","好不吉利","岌岌可危","安全","不安全","大吉大利",
                "吉","不吉利","非常吉利","好不吉利","岌岌可危","安全","不安全","大吉大利",
                "吉","不吉利","非常吉利","好不吉利","岌岌可危","安全","不安全","大吉大利",
                "吉","不吉利","非常吉利","好不吉利","岌岌可危","安全","不安全","大吉大利",
                "吉","不吉利","非常吉利","好不吉利","岌岌可危","安全","不安全","大吉大利",
                "吉","不吉利","非常吉利","好不吉利","岌岌可危","安全","不安全","大吉大利",
                "吉","不吉利","非常吉利","好不吉利","岌岌可危","安全","不安全","大吉大利",
                "吉","不吉利","非常吉利","好不吉利","岌岌可危","安全","不安全","大吉大利",
                "吉","不吉利","非常吉利","好不吉利","岌岌可危","安全","不安全","大吉大利",
                "吉","不吉利","非常吉利","好不吉利","岌岌可危","安全","不安全","大吉大利",};
        return arr[lastfour];//通过数组元素下标返回结果
    }
    public Boolean notRightSel(String strSel){
        if(strSel.length()!=11){//判断手机号码位数是否正确
            return false;
        }else{
            return true;
        }
    }
    public Boolean notInlandSel(String strSel){
        if(strSel.indexOf('1')!=0){//判断是否为大陆手机号码
            return true;
        }else{
            return false;
        }
    }
    public Boolean isDianxin(String strSel){
        String seltop = strSel.substring(0,3);
        if(seltop.equals("137")){//判断是否为137开头
            return true;
        }else{
            return false;
        }
    }
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/860340.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号