java设备imei号_java 怎么计算IMEI号码正确性

该博客介绍了一个Java程序,用于检查IMEI号码的正确性。通过计算偶数位置数字之和以及加倍后的奇数位置数字之和,判断IMEI号码是否符合校验规则,即两个和相加的总和是否能被10整除。
摘要由CSDN通过智能技术生成

展开全部

已完成,复制粘贴,采纳即636f707962616964757a686964616f31333337376362可。

public class IMEI

{

private static void checkIMEI ( String[] imei )

{

int even = 0, odd = 0;

for ( int i = 0; i 

{

int me = Integer.parseInt (imei[i].trim ());

if (i % 2 == 0)

{

even += me;

}

else

{

String tmp = 2 * me + "";

for ( int j = 0; j 

{

odd += Integer.parseInt (tmp.charAt (j) + "");

}

}

}

System.out.println ("The sum of the even-positioned digits is " + even);

System.out.println ("The sum of the digits in the doubled odd-positioned digits is " + odd);

int sum = even + odd;

if (sum % 10 == 0)

{

System.out.println ("This is a correct IMEI number because the sum of the sums (" + sum + ")\nis a multiple of 10.");

}

else

{

System.out.println ("This is not a correct IMEI number because the sum of the sums (" + sum + ")\n is not multiple of 10.");

}

}

public static void main ( String[] imei )

{

checkIMEI (imei);

}

}

da5707b78773e48deb176b4da4ca946d.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值