日期:2014-05-20 浏览次数:20775 次
import java.util.*;
public class Code {
public static void main(String[] args)
{
int a =1;
int b=2;
int c;
/*c=a;
a=b;
b=c;*/
a=a+b;
b=a-b;
a=a-b;
System.out.println("a= "+a+",b="+b);
System.out.println("这是一个\"拼爹\"年代");
Scanner scanner=new Scanner(System.in);
int l,w,s;
final double PI=3.1415926;
boolean reg=false;
if(reg==false){
try
{
System.out.println("输入长度:");
l=scanner.nextInt();
System.out.println("输入宽度:");
w=scanner.nextInt();
s=l*w;
System.out.println("长方形面积为= "+s);
}
catch(Exception e)
{
System.out.println("你输入的数字类型不对,重新输入?");
}
reg=true;
}
else
{
System.out.println("计算结束");
}
}
}
public static void main(String[] args) throws Exception {
int a = 1;
int b = 2;
int c;
/*c=a;
a=b;
b=c;*/
a = a + b;
b = a - b;
a = a - b;
System.out.println("a= " + a + ",b=" + b);
System.out.println("这是一个\"拼爹\"年代");
Scanner scanner = new Scanner(System.in);
int l, w, s;
final double PI = 3.1415926;
boolean reg = false;
while (!reg) {
try {
System.out.println("输入长度:");
l = scanner.nextInt();
System.out.println("输入宽度:");
w = scanner.nextInt();
s = l * w;
System.out.println("长方形面积为= " + s);
System.out.print("是否继续(y/n): ");
if ("n".equalsIgnoreCase(scanner.next())) {
reg = true;
}
} catch (Exception e) {
System.out.println("你输入的数字类型不对");
break;
}
}
System.out.println("计算结束");
}