Java條件陳述式練習

來源:互聯網
上載者:User

標籤: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條件陳述式練習

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.