標題:
TQC 203 判斷奇偶數
[打印本頁]
作者:
周政輝
時間:
2016-12-24 11:35
標題:
TQC 203 判斷奇偶數
使用者自行輸入一個數值
並使用方法來判斷是否為奇偶數
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:35
import java.util.*;
public class JPA02 {
static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
test();
test();
}
static void test() {
System.out.println("Input a integer:");
int i = input.nextInt();
if(i%2==0)
{
System.out.println("The number is even;");
}
else
{
System.out.println("The number is odd");
}
}
}
複製代碼
作者:
蔡庭豪
時間:
2016-12-24 11:38
import java.util.*;
public class JPA02 {
static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
System.out.println("Input an intrger:");
int num = input.nextInt();
test(num);
System.out.println("Input an intrger:");
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:40
import java.util.*;
public class JPA02 {
static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
System.out.println("Input an integer:");
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:58
import java.util.*;
public class JPA02 {
static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
System.out.println("Input an integer:");
int num = input.nextInt();
test(num);
System.out.println("Input an integer:");
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 numbr is odd.");
}
}
}
複製代碼
作者:
蔡季樺
時間:
2016-12-25 18:44
import java.util.*;
public class JPA02 {
static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
System.out.print("input an integer:");
int num = input.nextInt();
test(num);
System.out.print("input an integer:");
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");
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2