By GokiSoft.com| 15:42 05/09/2022|
Java Basic

Java Basic- Kiểm tra số chẵn và lẻ - mệnh đề điều kiên if - else trong java

Nhập số nguyên x, in ra x là số chẵn hay số lẻ

Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)

Nguyễn Anh Vũ [T2008A]
Nguyễn Anh Vũ

2021-01-25 09:20:22



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ChanLe;
import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class Test3 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        System.out.println("Nhap x = ");
        int x;
        Scanner scan = new Scanner(System.in);
        x = scan.nextInt();
        
        if (x % 2 == 0){
            System.out.println("x la so chan");
        }
        else {
            System.out.println("x la so le");
        }
    }
    
}



Đặng Trần Nhật Minh [T2008A]
Đặng Trần Nhật Minh

2021-01-22 09:43:30



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javalesson2;

import java.util.Scanner;
import static javafx.scene.input.KeyCode.X;

/**
 *
 * @author W10-2004
 */
public class ex03 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        Scanner r = new Scanner(System.in);
        
        int x;
        System.out.println("Input X: ");
        x = r.nextInt();
        String s;
        
        System.out.println(s = (x % 2 == 0)?("X is even"):("X is odd"));
    }
    
}



Do Trung Duc [T2008A]
Do Trung Duc

2021-01-21 04:02:38



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package gokisoft_lesson1;

import java.util.Scanner;

/**
 *
 * @author TrungDuc
 */
public class Kiemtrasochanle_If_Else {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        System.out.println("Nhap so x");
        int x = scan.nextInt();
        if (x % 2 == 0) {
            System.out.println("x la so chan");
        } else {
            System.out.println("x la so le");
        }

    }
}



Trần Thị Khánh Huyền [T2008A]
Trần Thị Khánh Huyền

2021-01-21 01:09:24



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sochanle;

import java.util.Scanner;
/**
 *
 * @author Admin
 */
public class SoChanLe {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
    Scanner nhap = new Scanner(System.in);
    
    int n;
    System.out.println("Nhap so nguyen: ");
    n = nhap.nextInt();
    
    if (n%2==0){
        System.out.println("n la so chan!");
    }
    else{
        Sys3tem.out.println("n la so le!");
    }
    }
    
}



hainguyen [T2008A]
hainguyen

2021-01-20 10:16:17



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package t2008a_1;

import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class T2008A_1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner scan = new Scanner (System.in);
        int x;
        
        System.out.println("Nhap x = ");
        x = scan.nextInt();
        System.out.println("x = " + x);
        if (x %2 == 0 ) {
            System.out.println("x la so chan");
        }
        else {
            System.out.println("x la so le");
        }
        
        System.out.println();
    }
    
}



Trần Văn Lâm [T2008A]
Trần Văn Lâm

2021-01-20 09:55:10



public class Test2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        int x;
        Scanner scan = new Scanner(System.in);
        System.out.println("Nhap x = ");
        x = scan.nextInt();
        
        if(x % 2 == 0){
            System.out.println("X la so chan");
        }
        else{
             System.out.println("X la so le");
        }
    }
    
}



Đỗ Minh Quân [T2008A]
Đỗ Minh Quân

2021-01-20 09:31:47



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package t2008a;

import java.util.Scanner;
import javax.sound.midi.Soundbank;

/**
 *
 * @author PC
 */
public class T2008A {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
      Scanner scan = new Scanner(System.in);
        int A;
        System.out.print("Nhap so A = ");
        A = scan.nextInt();
        if (A % 2 == 0) {
            System.out.print("la so chan");
        } else {
            System.out.print("la so le");
        }
    
       
       
        
        
    }
    
}



Nguyễn Hữu Hiếu [T2008A]
Nguyễn Hữu Hiếu

2021-01-20 09:28:35



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package aptech;

import java.util.Scanner;

/**
 *
 * @author UserName
 */
public class Ex3 {

    public static void main(String[] args) {

        System.out.println("Nhap x =");

        int x;

        Scanner scan = new Scanner(System.in);
        x = scan.nextInt();

        if (x % 2 == 0) {
            System.out.println("x là so chan");
        } else {
            System.out.println("x là so le");
        }

    }

}



vuong huu phu [T2008A]
vuong huu phu

2021-01-20 09:11:59



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package bai_1;

import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class Bai_tap {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner scan = new Scanner(System.in);
        int x;
        System.out.print("Nhap so X = ");
        x = scan.nextInt();
        if (x % 2 == 0) {
            System.out.print("X la so chan");
        } else {
            System.out.print("X la so le");
        }
    }

}



Triệu Văn Lăng [T2008A]
Triệu Văn Lăng

2021-01-20 09:11:29



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package baitap;

import java.util.Scanner;

/**
 *
 * @author MTLS
 */
public class bai976 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner scan = new Scanner(System.in);
        
        int x;
        System.out.println("Nhap x= ");
        x = scan.nextInt();
        
        System.out.println("x = " + x);
        
        if (x%2==0) {
            System.out.println("x la so chan");
        }
        else {
            System.out.println("x la so le");
        }
    }
    
}