Answer to Question #299725 in Java | JSP | JSF for JEZ

Question #299725

Create a flowchart and a java program of the problem stated as follows. Create

user-defined methods that will perform 4 functionalities of an Automated Teller

Machine(Withdraw, Deposit, Transfer, Balance Check)

1. Withdraw (method name: withdraw)

* Input the amount to be withdrawn. Compute for the remaining balance after

the operation (balance = balance - withdrawn)

2. Deposit (method name: deposit)

* Input the amount to be deposited. Compute for the updated balance after

the operation (balance = balance + deposit)

3. Transfer (method name: transfer)

*Input the account number and the amount to be transferred. Compute for the

updated balance after the operation (balance = balance – moneySent)

4. Balance Check (method name: balanceCheck)

* Display the remaining balance.


1
Expert's answer
2022-02-19T02:38:57-0500
import java.util.Scanner;

public class Main {
    private static double balance = 1000;

    public static void withdraw(Scanner in) {
        System.out.println("Input the amount to be withdrawn:");
        balance -= in.nextDouble();
    }

    public static void deposit(Scanner in) {
        System.out.println("Input the amount to be deposit:");
        balance += in.nextDouble();
    }

    public static void transfer(Scanner in) {
        System.out.println("Input the account number and the amount to be transferred:");
        int accountNumber = in.nextInt();
        balance -= in.nextDouble();
    }

    public static void balanceCheck() {
        System.out.println("Balance: " + balance);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("1. Withdraw\n2. Deposit\n3. Transfer\n4. Balance check");
        switch (in.nextInt()) {
            case 1:
                withdraw(in);
                break;
            case 2:
                deposit(in);
                break;
            case 3:
                transfer(in);
                break;
            case 4:
                balanceCheck();
                break;
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS