作業(yè)代碼(非最優(yōu)

import java.util.*;
public class njava06{
? public static void main(String[]args){
? ? //get imformation;
? ? System.out.println("Please enter your id :");
? ? Scanner in = new Scanner(System.in);
? ? String id = in.nextLine();
? ? int[] arr = new int[18];
? ? for (int i = 0;i < id.length();i++){
? ? ? String cup = String.valueOf(id.charAt(i));
? ? ? int num = Integer.parseInt(cup);
? ? ? arr[i] = num;
? ? }
? ? //computer the imformation;
? ? int year = 1000*arr[6]+100*arr[7]+10*arr[8]+arr[9];
? ? int month = 10*arr[10]+arr[11];
? ? int day = 10*arr[12]+arr[13];
? ? System.out.println("Please enter the year :");
? ? int nowYear = in.nextInt();
? ? System.out.println("Please enter the month :");
? ? int nowMonth = in.nextInt();
? ? System.out.println("Please enter the day :");
? ? int nowDay = in.nextInt();
? ? System.out.println("You born on "+year+"/"+month+"/"+day);
? ? //make a choice and print out;
? ? if(nowMonth == month){
? ? ? if(nowDay >= day){
? ? ? ? int age = nowYear - year;
? ? ? ? System.out.println("You are "+age+"years old.");
? ? ? }
? ? ? else{
? ? ? ? int age = nowYear - year -1;
? ? ? ? System.out.println("You are "+age+"years old.");
? ? ? }
? ? }
? ? else if(nowMonth > month){
? ? ? int age = nowYear - year;
? ? ? System.out.println("You are "+age+"years old.");
? ? }
? ? else{
? ? ? int age = nowYear - year -1;
? ? ? System.out.println("You are "+age+"years old.");
? ? }
? ? if(arr[16]%2 == 0){
? ? ? System.out.println("You are female");
? ? }
? ? else{
? ? ? System.out.println("You are male");
? ? }
? ? //get the code of imformation;
? ? int point = 0;
? ? for(int i = 0;i < id.length();i++){
? ? ? int b = arr[i]*((int)(java.lang.Math.pow(2,i))%11);
? ? ? point += b;
? ? }
? ? int codeInf = point%11;
? ? System.out.print("The code imformation is ");
? ? if(codeInf == 0){
? ? ? System.out.print(1);
? ? }
? ? else if(codeInf == 1){
? ? ? System.out.print(0);?
? ? }
? ? else if(codeInf == 2){
? ? ? System.out.print('X');
? ? }
? ? else{
? ? ? System.out.print(12-codeInf);?
? ? }
? }
}