By GokiSoft.com| 15:18 20/01/2021|
Java Basic

[Share Code] Tạo dự án đầu tiên + biến & toán tử + Scanner - Lập trình Java



/*
 * 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 Diep.Tran
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        System.out.println("Hello World!!!");
        
        int x = 5;
        float y = 10;
        char c = 'A';
        String s = "TRAN VAN DIEP";
        
        System.out.println("x = " + x);
        System.out.println("y = " + y);
        System.out.println("s = " + s);
        
        System.out.println("x = " + x + ", y = " + y);
        
        System.out.format("x = %d, y = %f, s = %s", x, y, s);
        System.out.println("");
        
        //Nhap du lieu tu ban phim
        Scanner scan = new Scanner(System.in);
        
        int t;
        System.out.println("Nhap T = ");
        t = scan.nextInt();
        
        System.out.println("Nhap Y = ");
        y = scan.nextFloat();
        
        System.out.println("t = " + t + ", y = " + y);
    }
    
}




Tags:

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

5

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