By GokiSoft.com| 20:12 10/04/2024|
Java Basic

[Share Code] Tìm hiểu Java 2 - C2307L

#C2307L.java

/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template
 */

package com.gokisoft.c2307l;

import java.util.Scanner;

/**
 * @author diepvan
 * C2307L -> Class Object (Trung vs ten File)
 */
public class C2307L {
    static enum STUDENT_STATUS {PENDING, LEARNING, DROPOUT, PASS};
    
    public static void main(String[] args) {
        System.out.println("Hello World!");
        System.out.println("Xin chao");
        int x;
        float a = 12.5F;
        char c;
        String s;
        
        x = 10;
        c = 'A';
        s = "Sinh vien Aptech 54 Le Thanh Nghi";
        
        System.out.println("s = " + s);
        System.out.println("x = " + x + ", a = " + a);
        
        System.err.format("\nx = %d, a = %f, s = %s\n", x, a, s);
        
        final int ABC = 12; //Ky tu trong bien viet HOA
        
        //Trang thai cua bong den: sang, tat
        int status = 0;//0: tat, 1: Sang
        int studentStatus = 0;//0: Pending, 1: Learning, 2: Dropout, 3: .....
        
        STUDENT_STATUS sStatus = STUDENT_STATUS.PENDING;
        
        //Nhap du lieu tu ban phim bang cach nao
        Scanner scan = new Scanner(System.in);
        
        System.out.println("Nhap s = ");//Hien thi -> cho nguoi dung hieu dang lam gi
        s = scan.nextLine();
        
        System.out.println(s);
        
        System.out.println("Nhap x = ");
        x = Integer.parseInt(scan.nextLine()); //B1. Nhap string, B2. Chuyen string -> int (Integer.parseInt)
        System.out.println("x = " + x);
        
        System.out.println("Nhap s = ");//Hien thi -> cho nguoi dung hieu dang lam gi
        s = scan.nextLine();
        
        System.out.println(s);
    }
    
    void abc() {
        //Code
        //Code
    }
}
Tags:

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

5

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