## 문제
```
Deposit(in 000)
Annual Interest(1 year time deposit): 1.0% (not over KRW 5,000)
Annual Interest(1 year time deposit): 1.5% (KRW 5,000 ~ KRW 7,500)
Annual Interest(1 year time deposit): 1.75% (KRW 7,500 ~ KRW 12,500)
Annual Interest(1 year time deposit): 1.95% (KRW 12,500~ KRW 20,000)
Annual Interest(1 year time deposit): 2.15% (KRW 20,000 ~ KRW 30,000)
Annual Interest(1 year time deposit): 2.25% (over KRW 30,000)
Annual Interest(2 year time deposit): 1.1% (not over KRW 5,000)
Annual Interest(2 year time deposit): 1.55% (KRW 5,000 ~ KRW 7,500)
Annual Interest(2 year time deposit): 1.85% (KRW 7,500 ~ KRW 12,500)
Annual Interest(2 year time deposit): 2.05% (KRW 12,500~ KRW 20,000)
Annual Interest(2 year time deposit): 2.25% (KRW 20,000 ~ KRW 30,000)
Annual Interest(2 year time deposit): 2.35% (over KRW 30,000)
Tax: 5% from the interest
```
자바프로그래밍을 사용하여 Time deposit 과 year의 전체 돈 (이자율을 + /세금은 -)하여 각 각의 년도가 지난 뒤의 값을 나타내어라.
예시)
```
Input Time Deposit: 10,000,000
Input Year : 2
The future amount is :
10,351,500
```
How to get the result:
10,000,000 + (10,000,000 * 0.0185 * 2) – ((10,000,000 * 0.0185 * 2) * 0.05) = 10,351,500
단,IF/ESE statement and Methods만을 사용하라!
---------------------------------------------------------------------------------------------------------------
## 코드
```
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
System.out.print("Input Time Deposit : ");
int Deposit = console.nextInt();
System.out.print("Input Year : ");
int year = console.nextInt();
if (year == 1) {
System.out.println("1 year time deposit : ");
}
if (Deposit <= 5000); {
System.out.println(Deposit +(Deposit*0.01*year)-((Deposit*0.01*year)*0.05));
}
if (Deposit > 5000);
else if (Deposit <= 7500){
System.out.println(Deposit +(Deposit*0.015*year)-((Deposit*0.15*year)*0.05));
}
if (Deposit <= 7500);
else if (Deposit <= 12500){
System.out.println(Deposit +(Deposit*0.0175*year)-((Deposit*0.0175*year)*0.05));
}
if (Deposit <= 12500);
else if (Deposit <= 20000){
System.out.println(Deposit +(Deposit*0.0195*year)-((Deposit*0.0195*year)*0.05));
}
if (Deposit <= 20000);
else if (Deposit <= 30000){
System.out.println(Deposit +(Deposit*0.0215*year)-((Deposit*0.215*year)*0.05));
}
else if (Deposit > 30000){
System.out.println(Deposit +(Deposit*0.0225*year)-((Deposit*0.225*year)*0.05));
}
if( year == 2 ) {
System.out.println("2 year time deposit : ");
if (Deposit < 5000); {
System.out.println(Deposit +(Deposit*0.011*year)-((Deposit*0.011*year)*0.05));
}
if (Deposit > 5000);
else if (Deposit <= 7500){
System.out.println(Deposit +(Deposit*0.0155*year)-((Deposit*0.55*year)*0.05));
}
if (Deposit <= 7500);
else if (Deposit <= 12500){
System.out.println(Deposit +(Deposit*0.0185*year)-((Deposit*0.0185*year)*0.05));
}
if (Deposit <= 12500);
else if (Deposit <= 20000){
System.out.println(Deposit +(Deposit*0.0205*year)-((Deposit*0.0205*year)*0.05));
}
if (Deposit <= 20000);
else if (Deposit <= 30000){
System.out.println(Deposit +(Deposit*0.0225*year)-((Deposit*0.225*year)*0.05));
}
else if (Deposit > 30000){
System.out.println(Deposit +(Deposit*0.0235*year)-((Deposit*0.235*year)*0.05));
}
}
}
}
```
이런 식으로 코드를 사용하여 보았는데 콘솔 창에
```
Input Time Deposit : 50000001
Input Year : 1
```
을 입력하여도 한 개의 값만 나오게 하고 싶은데 2가지가 나오고,
```
Input Time Deposit : 50000001
Input Year : 2
```
을 입력하면 Year 2에 해당하는 값만 불러내고 싶은데 Year1 값을 불러내고 Year2 값을 불러내고 싶은데 왜 그런 걸까요....
sehongpark님의 답변
## if-else
이런식으로 해보세요.
```
if (year == 1) {
if (deposit < 5000) {
// 생략..
} else if (deposit < 7500) {
// 생략..
} else if (deposit < 12500) {
// 생략..
} else if ...
...
} else {
}
```
## 참고 강의
+ 조건문 (https://cloudstudying.kr/lectures/174)