-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc1029.java
More file actions
27 lines (21 loc) ยท 1.04 KB
/
Copy pathc1029.java
File metadata and controls
27 lines (21 loc) ยท 1.04 KB
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
package codeup;
import java.util.Scanner;
//import java.math.BigDecimal;
public class c1029 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("์ค์ ์
๋ ฅ: ");
//BigDecimal bigDecimal = sc.nextBigDecimal();
double num = sc.nextDouble();
sc.close();
//1. printf์ ์ถ๋ ฅ๋ฌธ์ผ๋ก ์ถ๋ ฅ ํ์์ ๋ง์ถค
//System.out.printf("%.11f", num);
//2. String.format()์ ๋ฉ์๋๋ฅผ ์ด์ฉํ์ฌ ์ถ๋ ฅ ํ์์ ๋ง์ถค
//String.format() ๋ฉ์๋๋ฅผ ์ฌ์ฉํ๋ฉด C ์ธ์ด์ printf ํจ์์ฒ๋ผ ์์ ๋ฌธ์์ด์ ์ฌ์ฉํ " ํ์ ๋ฌธ์์ด " ์ ๋ง๋ค ์ ์๋ค
System.out.println(String.format("%.11f", num));
//System.out.println(bigDecimal);
}
}
//BigDecimal์ Java์ธ์ด์์ ์ซ์๋ฅผ ์ ๋ฐํ๊ฒ ์ ์ฅํ๊ณ ํํํ ์ ์๋ ์ ์ผํ ๋ฐฉ๋ฒ์ด๋ค. Double์ ์ ๋ฐ๋๊ฐ ๋จ์ด์ง๋ค.
//๋๊ณผ ์์์ ์ ๋ค๋ฃฌ๋ค๋ฉด BigDecimal์ ํ์์ด์ง๋ง ๋จ์ ์ ๋๋ฆฌ๋ค.
//String.format("์ถ๋ ฅํ์", ๋งค๊ฐ๋ณ์)๋ฅผ ์ด์ฉํ์ฌ ํ์์ ๋ฐ๊พธ์ด ์ถ๋ ฅํ๋ค.