charcha;//临时记录要转换的字符for(inti=1;i<=str.length();i++){cha=str.charAt(str.length()-i);switch(cha){case'1':lg=lg+1*jing;break;case'2':lg=lg+2*jing;break;case'3':lg=lg+3*jing;break;case'4':lg=lg+4*jing;break;case'5':lg=lg+5*jing;break;case'6':lg=lg+6*jing;break;case'7':lg=lg+7*jing;break;case'8':lg=lg+8*jing;break;case'9':lg=lg+9*jing;break;case'A':lg=lg+10*jing;break;case'B':lg=lg+11*jing;break;case'C':lg=lg+12*jing;break;case'D':lg=lg+13*jing;break;case'E':lg=lg+14*jing;break;case'F':lg=lg+15*jing;break;}jing*=j;//位权升一级,为下次使用做好准备}returnLong.toString(lg);}//endStringgoto_10()method}
三、详细设计importjava.awt.*;importjava.awt.event.*;classThis_number_too_bigextendsException{}//自定义的一个结果溢出异常类classJsp2003extendsFrameimplementsItemListener,ActionListener{publicJsp2003(){addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){dispose();System.exit(0);}});}staticJsp2003mainFrame=newJsp2003();staticLabellab=newLabel("0");staticPanelpnl1=newPanel(newGridLayout(4,3,3,3));staticPanelpnl2=newPanel(newGridLayout(4,1,3,3));
staticPanelpnl3=newPanel(newGridLayout(1,2,3,3));staticPanelpnl4=newPanel(newGridLayout(6,1,3,3));staticButtonbt9=newButton("9");staticButtonbt8=newButton("8");staticButtonbt7=newButton("7");staticButtonbt6=newButton("6");staticButtonbt5=newButton("5");staticButtonbt4=newButton("4");staticButtonbt3=newButton("3");staticButtonbt2=newButton("2");staticButtonbt1=newButton("1");staticButtonbt0=newButton("0");staticButtonbtdot=newButton(".");staticButtonbtequ=newButton("=");staticButtonbtadd=newButton("+");staticButtonbtsub=newButton("-");staticButtonbtmul=newButton("*");staticButtonbtdev=newButton("/");staticButtonbtA=newButton("A");staticButtonbtB=newButton("B");staticButtonbtC=newButton("C");staticButtonbtD=newButton(