package javahomework;
import javax.swing.JOptionPane;
public class HW06 {
public static void main(String args[]) {
int input;
input = Integer.parseInt(JOptionPane.showInputDialog(null, ""));
JOptionPane.showMessageDialog(null, "Check Number is " + Number(input));
}
static int Number(int n) {
return ((ADD(n) % ADD2(n)) % 10);
}
static int ADD(int n) {
if (n < 10)
return (n * n);
else
return (ADD(n / 10) + ADD(n % 10));
}
static int ADD2(int n) {
if (n < 10)
return n;
else
return (ADD2(n / 10) + ADD2(n % 10));
}
}
2008年8月29日 星期五
輸入一個數,計算其檢查碼
code
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言