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ẻ
Tags:
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]](https://www.gravatar.com/avatar/8863d24ed74b396082becbc4db8331fd.jpg?s=80&d=mm&r=g)
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]](https://www.gravatar.com/avatar/ee8dc5a777ad26f3a962e86c233437cf.jpg?s=80&d=mm&r=g)
Đặ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]](https://www.gravatar.com/avatar/2973ac07124f066b4605c535e8d39a99.jpg?s=80&d=mm&r=g)
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]](https://www.gravatar.com/avatar/554e115833778e4294a01aebe228f3d6.jpg?s=80&d=mm&r=g)
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]](https://www.gravatar.com/avatar/32855ce6db55d60134d830aee06b41e5.jpg?s=80&d=mm&r=g)
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]](https://www.gravatar.com/avatar/cfc15c8cb7781ad669b013e01f9f1a6b.jpg?s=80&d=mm&r=g)
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]](https://www.gravatar.com/avatar/fa40264d7c4b4209c87a9e9451d2b9f0.jpg?s=80&d=mm&r=g)
Đỗ 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]](https://www.gravatar.com/avatar/ca2884508b617fee77f000c7d99c219d.jpg?s=80&d=mm&r=g)
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]](https://www.gravatar.com/avatar/307a5cf29780afab49706dc8b15b86c6.jpg?s=80&d=mm&r=g)
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]](https://www.gravatar.com/avatar/1348e3562c6492c26f796cb1f45982a1.jpg?s=80&d=mm&r=g)
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");
}
}
}