首页 > 代码库 > Java条件语句练习
Java条件语句练习
/*System.out.println("请输入三个数字:");//输入三个数字,返回最大的那个。
int a,b,c,big;
Scanner d = new Scanner(System.in);
a = d.nextInt();
b = d.nextInt();
c = d.nextInt();
if(a>b)
{
big=a;
if(big<c)
{
big = c;
}
}
else
{
big=b;
if(big<c)
{
big = c;
}
}
System.out.println(big);*/
/*
System.out.println("请输入一元二次方程的三个系数");//一元二次方程根的情况
double a,b,c,d;
Scanner sc = new Scanner(System.in);
a = sc.nextDouble();
b = sc.nextDouble();
c = sc.nextDouble();
d = b*b-4*a*c;
if(a==0)
{
System.out.println("这不是一个一元二次方程");
}
else
{
if(d>0)
{
System.out.println("方程有两个实根");
}
else if(d==0)
{
System.out.println("方程有两个相等的实根");
}
else
{
System.out.println("方程没有实根");
}
}
*/
/*System.out.println("请输入一个年份");//输入一个年份看是否是闰年
Scanner sc = new Scanner(System.in);
int year = sc.nextInt();
if(year%4 == 0 && year%100 != 0 || year%400 == 0)
{
System.out.println(year+"是闰年");
}
else
{
System.out.println(year+"不是闰年");
}
*/
/*System.out.println("输入性别:身高:体重:");//判断身材是否标准
Scanner sc = new Scanner(System.in);
String sex = sc.nextLine();
double height = sc.nextDouble();
double weight = sc.nextDouble();
double biao;
if(sex.equals("男"))
{
biao = height - 100;
if(biao-3<height && biao+3>height)
{
System.out.println("good");
}
else if(biao-3>height)
{
System.out.println("thin");
}
else
{
System.out.println("fat");
}
}
else if(sex.equals("女"))
{
biao = height - 110;
if(biao-3<height && biao+3>height)
{
System.out.println("good");
}
else if(biao-3>height)
{
System.out.println("thin");
}
else
{
System.out.println("fat");
}
}
*/
Java条件语句练习