-
[JAVA연습] Banking System 1카테고리 없음 2022. 11. 8. 17:16
import java.util.Scanner;
public class BankingEx01 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String name = "";
long balance = 0L;
String strWork = "";
System.out.println("고객님 어서오십쇼! 이름을 입력해주세요.");
name = sc.next();
do {
System.out.println("===========================");
System.out.println("0.종료 | 1.입금 | 2.출금 | 3.잔액");
System.out.println("===========================");
System.out.println("선택 >> ");
strWork = sc.next();
int switchInt = 0; // switchCase문에 사용.
if (strWork != null) {
switchInt = Integer.parseInt(strWork);
} else {
System.out.println("선택없음");
System.exit(0);
}
switch (switchInt) {
case 0:
System.exit(0);
break;
case 1:
System.out.println("입금액 입력 : ");
String strDeposit = sc.next();
long depositLong = Long.parseLong(strDeposit);
balance += depositLong;
break;
case 2:
System.out.println("출금액 입력 : ");
String strwithdraw = sc.next();
long withdrawLong = Long.parseLong(strwithdraw);
balance -= withdrawLong;
break;
case 3:
System.out.println(name + "님의 잔액은" + balance + "원 입니다.");
break;
default:
System.out.println("0~3 숫자 입력 요구....");
break;
}
} while (!strWork.equals(0));
}
}