Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

ย 

History

History
History
27 lines (21 loc) ยท 1.04 KB

File metadata and controls

27 lines (21 loc) ยท 1.04 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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("์ถœ๋ ฅํ˜•์‹", ๋งค๊ฐœ๋ณ€์ˆ˜)๋ฅผ ์ด์šฉํ•˜์—ฌ ํ˜•์‹์„ ๋ฐ”๊พธ์–ด ์ถœ๋ ฅํ•œ๋‹ค.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.