No older revisions available
No older revisions available
~cpp SocialNumber.java
¶
~cpp
import java.util.Scanner;
public class SocialNumber
{
private String num;
public void input()
{
Scanner input = new Scanner(System.in);
num = input.next();
}
public boolean validate()
{
int validateNum[] = {2,3,4,5,6,7,8,9,2,3,4,5};
int sum = 0;
int key = (int)num.charAt(12) - 48;
for (int i = 0; i < 12; i++)
sum += ((int)num.charAt(i) - 48) * validateNum[i];
sum = 11 - (sum %11);
if (sum >= 10)
sum %= 10;
if (key == sum)
return true;
return false;
}
}
~cpp TestSocialNuber.java
¶
~cpp
public class TestSocialNumber
{
public static void main(String[] args)
{
SocialNumber socialNum = new SocialNumber();
socialNum.input();
boolean isRight = socialNum.validate();
if (isRight == true)
System.out.println("대한민국 국민이네요~ ^^ 안녕하세요!");
else
System.out.println("혹시 간첩???? -_-;;");
}
}