標題:
if...else if...else 判斷式 (一)
[打印本頁]
作者:
tonyh
時間:
2019-8-2 11:42
標題:
if...else if...else 判斷式 (一)
運用 if...else if...else 判斷式, 比較 x 與 y 的大小關係.
二擇一
if( )
{
}
else
{
}
多擇一
if( )
{
}
else if( )
{
}
else if( )
{
}
else
{
}
多擇多 / 多擇無
if( )
{
}
if( )
{
}
if( )
{
}
if( )
{
}
本帖隱藏的內容需要回復才可以瀏覽
作者:
潘憶承
時間:
2019-8-2 11:55
本帖最後由 潘憶承 於 2019-8-2 12:00 編輯
public class Ch09
{
public static void main(String args[])
{
Console c=System.console();
int x,y;
System.out.print("輸入x: ");
x=Integer.parseInt(c.readLine());
System.out.print("輸入y: ");
y=Integer.parseInt(c.readLine());
if(x<y)
System.out.print("x>y");
else if(x<y)
System.out.print("x<y");
else
System.out.print("x=y");
}
}
複製代碼
作者:
張郁庭
時間:
2019-8-2 11:57
import java.io.Console;
public class Ch07
{
public static void main(String args[])
{
int x,y;
Console c=System.console();
x=Integer.parseInt(c.readLine("請輸入x: "));
y=Integer.parseInt(c.readLine("請輸入y: "));
if(x>y)
System.out.println("x>y!");
else if(x<y)
System.out.println("x<y!");
else
System.out.println("x=y!");
}
}
複製代碼
作者:
許育慈
時間:
2019-8-2 11:57
import java.io.Console;
public class Ch10
{
public static void main(String args[])
{
int x,y;
Console c=System.console();
x=Integer.parseInt(c.readLine("請輸入x:"));
y=Integer.parseInt(c.readLine("請輸入y:"));
if(x>y)
{
System.out.print("x>y");
}else if(x<y)
{
System.out.print("x<y");
}else
{
System.out.print("x=y");
}
}
}
複製代碼
作者:
葉俠愷
時間:
2019-8-2 11:58
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x,y;
Console c=System.console();
x=Integer. parseInt(c.readLine("輸入x "));
y =Integer. parseInt(c.readLine("輸入y "));
if(x>y)
{System.out.println("x>y "); }
else if(x<y)
{System.out.println("x<y "); }
else{System.out.println("x=y ");}
}
}
複製代碼
作者:
許育禎
時間:
2019-8-2 11:59
import java.io.Console;
public class CH09
{
public static void main(String args[])
{
int x, y;
Console c=System.console();
System.out.print("請輸入x:");
x=Integer.parseInt(c.readLine());
System.out.print("請輸入y:");
y=Integer.parseInt(c.readLine());
if(x>y)
{
System.out.println("x>y");
}
else if(x<y)
{
System.out.println("x<y");
}
else
{
System.out.println("x=y");
}
}
}
複製代碼
作者:
黃永恩
時間:
2019-8-2 11:59
import java.io.Console;
public class ch05{
public static void main(String args[]){
String z;
int x,y;
Console c=System.console();
System.out.print("請輸入x: ");
x=Integer.parseInt(c.readLine());
System.out.print("請輸入y: ");
y=Integer.parseInt(c.readLine());
if(x>y)
z=">";
else if(x<y)
z="<";
else
z="=";
System.out.println("x"+z+"y!");
}
}
複製代碼
作者:
張書涵
時間:
2019-8-2 12:00
import java.io.Console;
public class Ch08
{
public static void main(String args[])
{
int x, y;
Console c=System.console();
System.out.print("請輸入x: ");
x=Integer.parseInt(c.readLine());
System.out.print("請輸入y: ");
y=Integer.parseInt(c.readLine());
if(x>y)
{
System.out.print("x大於y!");
}
else if(x==y)
{
System.out.print("x等於y!");
}
else
{
System.out.print("x小於y!");
}
}
}
複製代碼
作者:
黃芊嬡
時間:
2019-8-2 12:00
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x,y;
Console c=System.console();
x=Integer.parseInt(c.readLine("請輸入x:"));
y=Integer.parseInt(c.readLine("請輸入y:"));
if(x>y)
{
System.out.println("x大於y!");
}
else if(x<y)
{
System.out.println("x小於y!");
}
else
System.out.println("兩數相等!");
}
}
複製代碼
作者:
余奕廷
時間:
2019-8-2 12:01
import java.io.Console;
public class Ch01
{
public static void main(String args[])
{
Console c=System.console();
int x,y;
x=Integer.parseInt(c.readLine("輸入x值: "));
y=Integer.parseInt(c.readLine("輸入y值: "));
if(x>y)
{
System.out.println("x>y");
}else if(x<y)
{
System.out.println("x<y");
}else
System.out.println("x=y");
}
}
複製代碼
作者:
余映均
時間:
2019-8-2 12:02
public class Ch07
{
public static void main(String args[])
{
Console c=System.console();
int x,y;
System.out.print("請輸入x: ");
x=Integer.parseInt(c.readLine());
System.out.print("請輸入y: ");
y=Integer.parseInt(c.readLine());
if(x>y)
System.out.print("x大於y!");
else if(x<y)
System.out.print("x小於y!");
else
System.out.print("兩數相等!");
}
}
複製代碼
作者:
莊鈞程
時間:
2019-8-2 12:02
import java.io.Console;
public class Ch07
{
public static void main(String args[])
{
Console c=System.console();
int x,y;
x=Integer.parseInt(c.readLine("請輸入x: "));
y=Integer.parseInt(c.readLine("請輸入y: "));
if(x>y)
System.out.println("x大於y!");
else if(x==y)
System.out.println("兩數相等!");
else
System.out.println("x小於y!");
}
}
複製代碼
作者:
曾暘竣
時間:
2019-8-2 12:02
public class Ch06
{
public static void main(String args[])
{
Console c=System.console();
int x,y;
System.out.print("輸入x: ");
x=Integer.parseInt(c.readLine());
System.out.print("輸入y: ");
y=Integer.parseInt(c.readLine());
if(x>y)
System.out.print("x>y");
else if(x<y)
System.out.print("x<y");
else
System.out.print("x=y");
}
}
複製代碼
作者:
何育翔
時間:
2019-8-2 12:02
import java.io.Console;
public class Ch09
{
public static void main(String args[])
{
Console c=System.console();
int x,y;
System.out.print("輸入x:");
x=Integer.parseInt(c.readLine());
System.out.print("輸入y:");
y=Integer.parseInt(c.readLine());
if(x>y)
System.out.print("x>y");
else if(x<y)
System.out.print("x<y");
else
System.out.print("x=y");
複製代碼
作者:
鄭宇崴
時間:
2019-8-2 12:03
import java.io.Console;
public class Ch09
{
public static void main(String args[])
{
Console c=System.console();
int x,y;
System.out.print("輸入x: ");
x=Integer.parseInt(c.readLine());
System.out.print("輸入y: ");
y=Integer.parseInt(c.readLine());
if(x>y)
System.out.println("x>y");
else if(x<y)
System.out.println("x<y");
else
System.out.println("x=y");
}
}
複製代碼
作者:
蔡明蓉
時間:
2019-8-2 12:31
import java.io.Console;
public class Ch99
{
public static void main (String args[])
{
Console c=System.console();
int x,y;
System.out.print("請輸入x: ");
x=Integer.parseInt(c.readLine());
System.out.print("請輸入y: ");
y=Integer.parseInt(c.readLine());
if(x>y)
System.out.println("x>y");
else if (x<y)
System.out.println("x<y");
else
System.out.println("x=y");
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2