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 Sử [T2008A]
nguyễn Sử

2021-01-20 08:57:58



public static void main(String[] args) {
        // TODO code application logic here
        System.out.println("nhap so nguyen x");
        int x = 10;
        if (x % 2 == 0) {
            System.out.println(x+ " là số chẵn!");
        } else {
            System.out.println(x + " là số lẻ!");
        }
    }

}



Nguyễn Tiến Đạt [T2008A]
Nguyễn Tiến Đạt

2021-01-20 08:31:28



/*
 * 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 lesson1;

import java.util.Scanner;

/**
 *
 * @author MyPC
 */
public class chanle {
   public static void main(String[] args) {
        // TODO code application logic here
        Scanner scan = new Scanner(System.in);
        System.out.print("Nhap x = ");
        int x;
        x = scan.nextInt();
        if( x % 2 == 0 ) System.out.println("x là số chẵn");
        else System.out.println("x là số lẻ");
    }

}



Đinh Vũ Anh [C1907L]
Đinh Vũ Anh

2020-03-20 08:29:59



package Basic;

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

    /**
     * @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("Input x: ");
        x = scan.nextInt();
        
        if(x % 2 == 0){
            System.out.println("X là số chẵn");
        }else{
            System.out.println("X là số lẻ");
        }
    }
    
}



Lê Xuân Dũng [JavaFree]
Lê Xuân Dũng

2020-03-16 14:54:54



package bai03;

import java.util.Scanner;

public class Bai03 {
    public static void main(String[] args) {
        int x;
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap so nguyen x = ");
        x = sc.nextInt();

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



Trần Mạnh Dũng [T1907A]
Trần Mạnh Dũng

2020-03-16 12:57:56



package bt30;
import java.util.Scanner;
public class BT30 {
     
     public static void main(String[] args) {
        
        float x;
        
        Scanner scan = new Scanner(System.in);
            System.out.printf("Enter a number : ");
            x = scan.nextFloat();
            if(x%2==0){
                System.out.println("Numer is even");
            }else{
                System.out.println(" Number is odd");
            }
            }
}



Phạm Kim Anh [JavaFree]
Phạm Kim Anh

2020-03-16 07:19:06



package oop;

import java.util.Scanner;

public class SoChanLe {

	public static void main(String[] args) {
		int x;
		Scanner sc = new Scanner(System.in);
		
		System.out.println("Nhap so nguyen x: ");
		x = Integer.parseInt(sc.nextLine());
		
		if( x % 2 == 0 ) {
			System.out.println(x + " la so chan.");
		}else {
			System.out.println(x +" la so le.");
		}
	}
}



Nguyễn Hữu Đạt [C1907L]
Nguyễn Hữu Đạt

2020-03-16 05:04:19



package baitap;
 
import java.util.Scanner;
 
public class Bai1 {

 

    public static void main(String args[]) {
        int n;
        Scanner sc = new Scanner(System.in);
        System.out.print("n = ");
        n = sc.nextInt();
         
        if(n%2 == 0){
            System.out.format("%d la so chan", n);
        }
        else{
            System.out.format("%d la so le", n);
        }
    }
}



Hoàng Quang Huy [C1907L]
Hoàng Quang Huy

2020-03-15 08:51:26



import java.util.Scanner;
public class ex3 {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		System.out.println("Nhập số nguyên x: ");
		int x = Integer.parseInt(input.nextLine());
		if(x%2 == 0) {
			System.out.println(x +" là số chẵn");
		}else {
			System.out.println(x + " là số lẻ");
		}
	}
}



cuonglee [C1907L]
cuonglee

2020-03-14 13:43:56

package javabasic;
import java.util.Scanner;
/**
 *
 * @author Admin
 */
public class chanle {
    public static void main(String[] args) {
        Scanner can = new Scanner(System.in);
        System.out.println("Moi nhap n :");
        int n = Integer.parseInt(can.nextLine());
        if(n%2==0){
            System.out.println("so vua nhap la so chan!");
        }else{
            System.out.println("so vua nhap la so le");
        }
    }
}


Vũ Việt Đức [C1907L]
Vũ Việt Đức

2020-03-13 17:07:24



package aptech;
import java.util.Scanner;

public class Homework {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        
        System.out.print("Vui lòng nhập số: ");
        int x = input.nextInt();
        if((x % 2) == 0) {
            System.out.println(x + " là số chẵn");
        }
        else {
            System.out.println(x + " là số lẻ");
        }
    }
}