June is Combung
ATM[1단계] 본문
package week1;
import java.util.Scanner;
public class Day4_4 {
/*
* # ATM[1단계] : 이체하기
* 1. 이체할 계좌번호를 입력받는다.
* 2. 계좌번호가 일치하면,
* 3. 이체할 금액을 입력받는다.
* 4. 이체할 금액 <= myMoney : 이체가능
* myMoney - 이체할 금액
* yourMoney + 이체할 금액
* 이체할 금액 > myMoney : 이체불가
*/
public static void main(String[] args) {
//int myAcc = 1234;
int myMoney = 8700;
int yourAcc = 4321;
int yourMoney = 12000;
Scanner sc = new Scanner(System.in);
System.out.println("이체할 계좌번호를 입력하세요.");
int inputAcc = sc.nextInt();
if(inputAcc == yourAcc) {
System.out.println("이체할 금액을 입력하세요.");
int inputMoney = sc.nextInt();
if(inputMoney <= myMoney) {
myMoney -= inputMoney;
yourMoney += inputMoney;
}
else {
System.out.println("이체불가.");
}
}
System.out.println("myMoney = " + myMoney + "원");
System.out.println("yourMoney = " + yourMoney + "원");
sc.close();
}
}
'java > 조건문' 카테고리의 다른 글
369게임[1단계] (0) | 2021.03.23 |
---|---|
가운데 숫자 맞추기 게임 (0) | 2021.03.23 |
가위바위보 게임[2단계] (0) | 2021.03.23 |
홀짝게임 (0) | 2021.03.23 |
코인게임 (0) | 2021.03.23 |
Comments