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)
![Lê Đức Mạnh [C1907L]](https://www.gravatar.com/avatar/b07a8ad1b691824082e55e068f836398.jpg?s=80&d=mm&r=g)
Lê Đức Mạnh
2020-03-13 14:05:32
public static void main(String[] args) {
System.out.println("Kiem tra so chắn lẻ");
Scanner Bien = new Scanner(System.in);
System.out.println("Moi nhap so ");
int Nhap = Integer.parseInt(Bien.nextLine());
if (Nhap % 2 == 0) {
System.err.println("so chan");
}else{
System.err.println("so le");
}
![Nguyễn Hoàng Anh [C1907L]](https://www.gravatar.com/avatar/5b7bb435cae0d0a0fd414f6fdd0adc87.jpg?s=80&d=mm&r=g)
Nguyễn Hoàng Anh
2020-03-13 12:02:53
/*
* 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 myinfo;
import java.util.Scanner;
/**
*
* @author Redmibook 14
*/
public class MyInfo {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("Hello World");
System.out.printf("Ten : %s %nTuoi : %d%nDia Chi : %s%nEmail : %s%nSo Dien Thoai : %d%n","Nguyen Le Hoang"
+ " Anh",18,"267 Hoang Hoa Tham","lehoang7438@yahoo.com",01231321321);
Scanner input = new Scanner(System.in);
System.out.println("Moi nhap ho va ten : ");
String username = input.nextLine();
System.out.println("Moi nhap tuoi : ");
int tuoi = input.nextInt();
System.out.println("Moi nhap dia chi : ");
String diachi = input.nextLine();
System.out.println("Moi nhap email : ");
String email = input.nextLine();
System.out.println("Moi nhap so dien thoai : ");
int sdt = input.nextInt();
System.out.format("Ho va Ten :%s%nTuoi :%d%nDia chi :%s%nemail :%s%nsdt :%d", username ,tuoi, diachi, email,sdt);
System.out.println("/nMoi nhap so X : ");
int X = input.nextInt();
if(X % 2 != 0){
System.out.println("X la so Le ");
}else{
System.out.println("X la so Chan ");
}
}
}
![Nguyễn Hoàng Anh [C1907L]](https://www.gravatar.com/avatar/5b7bb435cae0d0a0fd414f6fdd0adc87.jpg?s=80&d=mm&r=g)
Nguyễn Hoàng Anh
2020-03-13 12:02:48
/*
* 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 myinfo;
import java.util.Scanner;
/**
*
* @author Redmibook 14
*/
public class MyInfo {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("Hello World");
System.out.printf("Ten : %s %nTuoi : %d%nDia Chi : %s%nEmail : %s%nSo Dien Thoai : %d%n","Nguyen Le Hoang"
+ " Anh",18,"267 Hoang Hoa Tham","lehoang7438@yahoo.com",01231321321);
Scanner input = new Scanner(System.in);
System.out.println("Moi nhap ho va ten : ");
String username = input.nextLine();
System.out.println("Moi nhap tuoi : ");
int tuoi = input.nextInt();
System.out.println("Moi nhap dia chi : ");
String diachi = input.nextLine();
System.out.println("Moi nhap email : ");
String email = input.nextLine();
System.out.println("Moi nhap so dien thoai : ");
int sdt = input.nextInt();
System.out.format("Ho va Ten :%s%nTuoi :%d%nDia chi :%s%nemail :%s%nsdt :%d", username ,tuoi, diachi, email,sdt);
System.out.println("/nMoi nhap so X : ");
int X = input.nextInt();
if(X % 2 != 0){
System.out.println("X la so Le ");
}else{
System.out.println("X la so Chan ");
}
}
}
![hoangkhiem [C1907L]](https://www.gravatar.com/avatar/d3627ce786997fab24d1b790c91c6368.jpg?s=80&d=mm&r=g)
hoangkhiem
2020-03-13 09:40:23
package baitap;
import java.util.Scanner;
/**
*
* @author Admin
*/
public class Baitap3 {
public static void main(String[] args) {
System.out.println("Kiem tra so chắn lẻ");
Scanner Bien = new Scanner(System.in);
System.out.println("Moi nhap so ");
int Nhap = Integer.parseInt(Bien.nextLine());
if (Nhap % 2 == 0) {
System.err.println("la so chan");
}else{
System.err.println("so le");
}
//int Nhap = Integer.parseInt((Bien.nextLine));
}
}
![Ngô Quang Huy [C1907L]](https://www.gravatar.com/avatar/8e54dbf5994077ce599f49278164ae79.jpg?s=80&d=mm&r=g)
Ngô Quang Huy
2020-03-12 14:57:41
package aptech;
import java.util.Scanner;
public class BT2 {
public static void main(String[] args) {
Scanner Scan = new Scanner(System.in);
System.out.print("Nhap so nguyen n: ");
int n = Scan.nextInt();
if (n % 2 == 0) {
System.out.println(n + " la so chan.");
} else {
System.out.println(n + " la so le.");
}
}
}
![trung [C1907L]](https://www.gravatar.com/avatar/67c23432e4710f33dd14e580d41b0379.jpg?s=80&d=mm&r=g)
trung
2020-03-12 14:25:45
/*
* 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 test;
import java.util.Scanner;
/**
*
* @author prdox
*/
//Viết chương trình hiển thị thông tin cá nhân của bạn bao gồm (tên, tuổi, địa chỉ, email, sđt)
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Nhap vao so nguyen: ");
int x = input.nextInt();
String result = (x%2 == 0) ? "So chan" : "So le";
System.out.println(result);
}
}
![Đỗ Văn Huấn [T1907A]](https://www.gravatar.com/avatar/04c40301dd027839d265b3c3c9dc6e6b.jpg?s=80&d=mm&r=g)
Đỗ Văn Huấn
2020-03-11 15:25:14
package BaiTapNgay11_3_2020.Kt_ChanLe;
import java.util.Scanner;
public class ChanLe {
public static void main(String[] args) {
Scanner Scan = new Scanner(System.in);
System.out.print("Nhap so nguyen n: ");
int n = Integer.parseInt(Scan.nextLine());
if (n % 2 == 0) {
System.out.println(n + " la so chan.");
} else {
System.out.println(n + " la so le.");
}
}
}