標題:
TQC+ 202 比較大小
[打印本頁]
作者:
周政輝
時間:
2016-12-24 11:27
標題:
TQC+ 202 比較大小
使用者自行輸入兩數值 來判斷大小
作者:
張健勳
時間:
2016-12-24 11:27
import java.util.Scanner;
class JPA02 {
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args) {
System.out.println("Input:");
int numA= keyboard.nextInt();
int numB= keyboard.nextInt();
test(numA,numB);
numA= keyboard.nextInt();
numB= keyboard.nextInt();
test(numA,numB);
}
public static void test(int numA , int numB) {
if( numA > numB ) {
System.out.println(numA +" is larger than " + numB);
}else if( numB > numA){
System.out.println(numB +" is larger than " + numA);
}
}
}
複製代碼
作者:
王彥甯
時間:
2016-12-24 11:27
import java.util.*;
class JPD02 {
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args) {
test();
test();
}
public static void test() {
System.out.println("Input:");
int i = keyboard.nextInt();
int h = keyboard.nextInt();
if(i>h)
{
System.out.printf("%d is lager than %d\n",i,h);
}
else if(i<h)
{
System.out.printf("%d is lager than %d\n",h,i);
}
}
}
複製代碼
作者:
蔡季樺
時間:
2016-12-24 11:28
import java.util.*;
class JPD02 {
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args) {
int num = keyboard.nextInt();
int num2 = keyboard.nextInt();
test(num,num2);
num = keyboard.nextInt();
num2 = keyboard.nextInt();
test(num,num2);
}
public static void test(int num,int num2) {
if(num>num2)
{
System.out.printf("%d is larger than %d",num,num2);
}else if(num<num2)
{
System.out.printf("%d is larger than %d",num2,num);
}
}
}
複製代碼
作者:
蔡季樺
時間:
2016-12-24 11:41
import java.util.*;
public class JPD02 {
static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
int num = input.nextInt();
test(num);
num = input.nextInt();
test(num);
}
static void test(int num) {
if(num%2==0)
System.out.println("the number is even");
else
System.out.println("the number is odd");
}
}
複製代碼
作者:
蔡庭豪
時間:
2016-12-24 11:41
import java.util.*;
class JPA02 {
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args) {
System.out.print("Input:");
int x = keyboard.nextInt();
int y = keyboard.nextInt();
test(x,y);
System.out.println(" ");
System.out.print("Input:");
int a = keyboard.nextInt();
int b = keyboard.nextInt();
test(a,b);
}
public static void test(int num1,int num2) {
if(num1>num2){
System.out.printf("%d is lager than %d",num1,num2);
}else if(num2>num1){
System.out.printf("%d is lager than %d",num2,num1);
}
}
}
複製代碼
作者:
謝瀞儀
時間:
2016-12-24 11:46
import java.util.Scanner;
class JPA02 {
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args) {
int num =keyboard.nextInt();
int num2 =keyboard.nextInt();
test(num,num2);
num =keyboard.nextInt();
num2 =keyboard.nextInt();
test(num,num2);
}
public static void test(int num,int num2)
{
if(num>num2)
{
System.out.println(num+" is larger than "+num2);
}
else if(num==num2)
{
System.out.println(num+" is equal "+num2);
}
else
{
System.out.println(num2+" is larger than "+num);
}
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2