반응형
Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

디케이

자바: float 소수점 자릿수 정하기 본문

Java

자바: float 소수점 자릿수 정하기

디케이형 2020. 11. 26. 11:19
반응형
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		float n = sc.nextFloat();	//소수점 입력 받음
		String str = String.format("%.6f", n); 	//소수점 6자리 까지 반올림 저장
		System.out.println(str);	//저장된 str 소숫점 6자리까지 출력
	}
}
반응형