자바 프로그래밍

자바 프로그래밍

작성일 2023.05.02댓글 1건
    게시물 수정 , 삭제는 로그인 필요

profile_image 익명 작성일 -

import java.util.Scanner; class Account { private int balance; private int PIN; private int accountNumber; public Account(int initialBalance, int initialPIN, int accountNumber) { this.balance = initialBalance; this.PIN = initialPIN; this.accountNumber = accountNumber; } public int getBalance() { return this.balance; } public int getPIN() { return this.PIN; } public int getAccountNumber() { return this.accountNumber; } public void deposit(int amount) { this.balance += amount; } public void withdraw(int amount) { this.balance -= amount; } public void transfer(Account to, int amount) { this.withdraw(amount); to.deposit(amount); } } public class ATM { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("PIN을 입력하시오: "); int pin = scanner.nextInt(); Account account = new Account(0, pin, pin); int choice; do { System.out.println("\n1. 현금 입금"); System.out.println("2. 현금 인출"); System.out.println("3. 계좌 이체"); System.out.println("4. 종료"); System.out.print("번호를 선택하세요: "); choice = scanner.nextInt(); switch (choice) { case 1: System.out.print("입금액: "); int depositAmount = scanner.nextInt(); account.deposit(depositAmount); System.out.println("현재 잔액은 " + account.getBalance() + "원입니다."); break; case 2: System.out.print("인출액: "); int withdrawAmount = scanner.nextInt(); if (withdrawAmount > account.getBalance()) { System.out.println("잔액이 부족합니다."); } else { account.withdraw(withdrawAmount); System.out.println("현재 잔액은 " + account.getBalance() + "원입니다."); } break; case 3: System.out.print("이체액: "); int transferAmount = scanner.nextInt(); System.out.print("이체 계좌 번호: "); int transferAccountNumber = scanner.nextInt(); Account transferAccount = new Account(0, transferAccountNumber, transferAccountNumber); // 이체 대상 계좌 // 계좌번호에 해당하는 계좌 찾기 (가정) if (transferAmount > account.getBalance()) { System.out.println("잔액이 부족합니다."); } else { account.transfer(transferAccount, transferAmount); System.out.println("이체되었습니다."); System.out.println("현재 잔액은 " + account.getBalance() + "원입니다."); } break; case 4: System.out.println("프로그램을 종료합니다."); break; default: System.out.println("잘못된 입력입니다. 다시 입력하세요."); break; } } while (choice != 4); } }

계좌정보와 PIN에 대한 정책 정보가 부족하여 위와같이 코딩했습니다.

도움이 되셨으면 좋겠습니다.

자바 프로그래밍 코드

이 3개의 자바 프로그래밍 코드를 혹시 알수있을까요 나머진 다 풀었는데 이 3개가 막히네요.. 1. < " """ 2. < < 3. " " < " " " " "" "" 소스를 참고하세요

자바 프로그래밍 변수 초기화

자바 배우는 프린이 입니다. 코딩할 때, 어떤 문제는 변수 초기화 시켜 놓고 프로그래밍을 짜는데, 어떤 문제는 변수 초기화를 프로그래밍 하면서 필요할 때 마다 꺼내 쓰듯이...

자바프로그래밍

얼마보내드리면 되나요?? 네. 가능하시는대로 구매를 하시면 되겠습니다. 간단한 자바 프로그래밍은 25,000원, 좀 더 복잡한 자바 프로그래밍은 30,000원 정도 합니다.

자바 프로그래밍

자바 스크립트랑 자바프로그래밍이랑 다른 건가요? 다르다면 어떤 점이 다르나요? 자바 프로그래밍은 바이트코드라는 중간언어가 컴파일 또는 빌드 후에 생성된 것을 확인할 수...

자바프로그래밍 관련해서 알려주세요

자바프로그래밍 배우고 싶은데요 독학하는 건 많이... 어떻게 하는게 좋을까요ㅜㅠ 자바프로그래밍 진짜 배우고... 우선 자바프로그래밍 관련해서 문의를 남겨주셨습니다...

자바프로그래밍 기초실습 교육해주는 학원?

자바프로그래밍 기초실습 교육해주는 학원 추천좀 해주세요 ~~! 학교에서 자바프로그래밍을 배우는데 도저히 이해가 안되고 못따라가겠어서..ㅠㅠ 자바프로그래밍 기초부터...