无聊的我又来了..
复制程式
public class Test{
public static void main(String[] args) throws Exception{
Test t = new Test();
java.io.BufferedReader input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
while(true){
System.out.print("Please enter a number(1~50,0 for exit): ");
String stTemp = input.readLine();
int iTemp = 0;
try{
iTemp = Integer.parseInt(stTemp);
}
catch(Exception e){
System.out.println("parse number error, plz enter a valid number.");
break;
}
if(iTemp==0){
System.out.print("exit.");
break;
}
else if(iTemp<0){
System.out.println("negative number!");
}
else if(iTemp>50){
System.out.println("number > 50.");
}
else{
for(int i=1;i<=iTemp;i++){
System.out.println(""+i+"*"+i+"="+(i*i));
}
}
}
}
}