標題:
if...else if...else 判斷式 (一)
[打印本頁]
作者:
tonyh
時間:
2021-8-21 20:03
標題:
if...else if...else 判斷式 (一)
運用 if...else if...else 判斷式, 比較 x 與 y 的大小關係.
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");
}
}
複製代碼
作者:
林鼎傑
時間:
2021-8-21 20:21
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");
}
}
複製代碼
作者:
俞成章
時間:
2021-8-21 20:22
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");
}
}
複製代碼
作者:
林佑宸
時間:
2021-8-21 20:22
import java.io.Console;
public class Ch10
{
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");
}
}
複製代碼
作者:
林土水
時間:
2021-8-21 20:22
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");
}
}
複製代碼
作者:
王秉鈞
時間:
2021-8-21 20:23
import java.io.Console;
public class Ch07
{
public static void main(String args[])
{
Console c=System.console();
int x=Integer.parseInt(c.readLine("x的值: "));
int y=Integer.parseInt(c.readLine("y的值: "));
(x>y)
System.out.println("x大於y");
else if(x<y)
System.out.println("x小於y");
else
System.out.println("x等於y");
}
}
複製代碼
作者:
黃子倢
時間:
2021-8-21 20:23
import java.io.Console;
public class Ch11
{
public static void main(String args[])
{
Console c=System.console();
int x=Integer.parseInt(c.readLine("X的值:"));
int 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");
}
}
複製代碼
作者:
朱奕祐
時間:
2021-8-21 20:24
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");
}
}
複製代碼
作者:
冠宇
時間:
2021-8-21 20:24
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");
}
}
複製代碼
作者:
許洧熏
時間:
2021-8-21 20:26
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");
}
}
複製代碼
作者:
呂尚霖
時間:
2021-8-21 20:29
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");
}
}
複製代碼
作者:
陳志祐
時間:
2021-8-21 20:34
import java.io.Console;
public class Ch10
{
public static void main(String args[])
{
Console c=System.console();
int x=Integer .parseInt(c.readLine("x的值: "));
int y=Integer .parseInt(c.readLine("y的值: "));
if(x>y)
System.out.println("x大於y");
else if(x<y)
System.out.println("x小於y");
else
Syeyem.out.println("兩數相等");
}
}
複製代碼
作者:
余柏緯
時間:
2021-8-21 20:41
import java.lang.System;
import java.io.Console;
public class Ch12
{
public static void main(String args[])
{
Console c=System.console();
int a=Integer.parseInt(c.readLine("請輸入a:"));
int b=Integer.parseInt(c.readLine("請輸入b:"));
if(a<b)
{
System.out.println("b比較大!");
}else if(a>b)
{
System.out.println("a比較大!");
}else
{
System.out.println("兩數相等!");
}
}
}
複製代碼
作者:
蔡寓珉
時間:
2021-8-21 20:48
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");
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2