標籤:next can string 返回 double height 條件 str sys
/*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條件陳述式練習