PLEASE CREATE A FLOWCHART FOR THIS PROGRAM: user-defined methods is performed. Sample output is attached. 4 functionalities of an Automated Teller  Machine(Withdraw, Deposit, Transfer, Balance Check)   import java.util.Scanner; public class ATM {         double balance = 0, withdrawn, deposit;         static Scanner sc = new Scanner(System.in);// creating scanner object         public void Withdraw() {// method withdraw                 System.out.println("Enter the amount to be withdrawn");                 withdrawn = sc.nextDouble();// read the amount to be withdrawn                 balance = balance - withdrawn;// calculating balance                 if (balance < withdrawn) {// check sufficient balance in account                         System.out.println("Insufficient Balance");// if not,print insufficient balance                         if (balance < 0) {                                 balance = 0;                         }                 } else {// otherwise,print collect money.                         System.out.println("collect your money..");                 }                 System.out.println("Check Balance 1.Yes 2.No");// to check the balance in account                 int check = sc.nextInt();// if want to check,then read the yes                 if (check == 1) {// if yes,then print balance                         System.out.println("Balance := " + balance);                 } else {// otherwise return to calling function                         return;                 }         }         public void Deposit() {// method deposit                 System.out.println("Enter amount to be deposited :");                 deposit = sc.nextDouble();// read the amount to be deposited                 balance = balance + deposit;// add the deposited balance to balance                 System.out.println("Check Balance 1.Yes 2.No");                 int check = sc.nextInt();// check whether want to display the balance                 if (check == 1) {// if 1,then want to check the balance.                         System.out.println("Balance := " + balance);                 } else {// otherwise return to calling function                         return;                 }         }         public void Transfer()         {              System.out.println("Enter account number :");              double account_number = sc.nextDouble();// read the account number              System.out.println("Ente amount :");              double moneysent = sc.nextDouble();// read the amount to be transferred               balance = balance-moneysent;                                    }         public void CheckBalance() {                  System.out.println("Balance = " + balance);// Display the balance         }         public static void main(String[] args) {             ATM atm = new ATM();// creating object of class.                 while (true) {                         System.out.println("--------ATM--------\n1.Withdraw\n2.Deposit\n3.Transfer\n4.check Balance\n5.EXIT");// display the                                                                                                                                                                       // menu                         int choice;                         choice = sc.nextInt();// read the choice                         switch (choice) {                         case 1:// if 1,call method withdraw                                 atm.Withdraw();                                 break;                         case 2:// if 2,call deposit                                 atm.Deposit();                                 break;                         case 3:// if 3,call checkbalance                                 atm.Transfer();                         case 4:// if 3,then transfer                                                                          atm.CheckBalance();                                 break;                         case 5:  //if 5,then exit from loop.                                  System.exit(0);                         }                 }         } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

PLEASE CREATE A FLOWCHART FOR THIS PROGRAM:

user-defined methods is performed. Sample output is attached.

4 functionalities of an Automated Teller 
Machine(Withdraw, Deposit, Transfer, Balance Check)

 

import java.util.Scanner;

public class ATM {
        double balance = 0, withdrawn, deposit;
        static Scanner sc = new Scanner(System.in);// creating scanner object

        public void Withdraw() {// method withdraw
                System.out.println("Enter the amount to be withdrawn");
                withdrawn = sc.nextDouble();// read the amount to be withdrawn
                balance = balance - withdrawn;// calculating balance
                if (balance < withdrawn) {// check sufficient balance in account
                        System.out.println("Insufficient Balance");// if not,print insufficient balance
                        if (balance < 0) {
                                balance = 0;
                        }
                } else {// otherwise,print collect money.
                        System.out.println("collect your money..");
                }
                System.out.println("Check Balance 1.Yes 2.No");// to check the balance in account
                int check = sc.nextInt();// if want to check,then read the yes
                if (check == 1) {// if yes,then print balance
                        System.out.println("Balance := " + balance);
                } else {// otherwise return to calling function
                        return;
                }
        }

        public void Deposit() {// method deposit
                System.out.println("Enter amount to be deposited :");
                deposit = sc.nextDouble();// read the amount to be deposited
                balance = balance + deposit;// add the deposited balance to balance
                System.out.println("Check Balance 1.Yes 2.No");
                int check = sc.nextInt();// check whether want to display the balance
                if (check == 1) {// if 1,then want to check the balance.
                        System.out.println("Balance := " + balance);
                } else {// otherwise return to calling function
                        return;
                }
        }
        public void Transfer()
        {
             System.out.println("Enter account number :");
             double account_number = sc.nextDouble();// read the account number
             System.out.println("Ente amount :");
             double moneysent = sc.nextDouble();// read the amount to be transferred
              balance = balance-moneysent;
             
            
        }

        public void CheckBalance() { 
                System.out.println("Balance = " + balance);// Display the balance
        }

        public static void main(String[] args) {
            ATM atm = new ATM();// creating object of class.
                while (true) {
                        System.out.println("--------ATM--------\n1.Withdraw\n2.Deposit\n3.Transfer\n4.check Balance\n5.EXIT");// display the
                                                                                                                                                                      // menu
                        int choice;
                        choice = sc.nextInt();// read the choice
                        switch (choice) {
                        case 1:// if 1,call method withdraw
                                atm.Withdraw();
                                break;
                        case 2:// if 2,call deposit
                                atm.Deposit();
                                break;
                        case 3:// if 3,call checkbalance
                                atm.Transfer();
                        case 4:// if 3,then transfer                                         
                                atm.CheckBalance();
                                break;
                        case 5:  //if 5,then exit from loop.
                                 System.exit(0);

                        }
                }
        }

}

-ATM-
---------ATM--
1. Withdraw
2. Deposit
3. Transfer
1. Withdraw
2. Deposit
3. Transfer
4. Check Balance
4. Check Balance
5. EXIT
5. EXIT
Choose operation:1
Choose operation: 1
Enter amount to be withdrawn: 1000
Enter amount to be withdrawn: 6000
Collect your money
Insufficient Balance
Check Balance? 1. Yes 0. No: 1
Check Balance? 1. Yes 0. No: 1
Balance: 4000
Balance: 4500
-ATM-
-ATM-
1. Withdraw
2. Deposit
1. Withdraw
2. Deposit
3. Transfer
3. Transfer
4. Check Balance
4. Check Balance
5. EXIT
Choose operation: 2
Enter amount you want to deposit: 500
Check Balance? 1. Yes 0. No: 0
5. EXIT
Choose operation: 3
Balance: 4500
*Note: The initial balance is 0. The user is given an option to check the balance or not.
The program will run until the exit option is chosen.
Transcribed Image Text:-ATM- ---------ATM-- 1. Withdraw 2. Deposit 3. Transfer 1. Withdraw 2. Deposit 3. Transfer 4. Check Balance 4. Check Balance 5. EXIT 5. EXIT Choose operation:1 Choose operation: 1 Enter amount to be withdrawn: 1000 Enter amount to be withdrawn: 6000 Collect your money Insufficient Balance Check Balance? 1. Yes 0. No: 1 Check Balance? 1. Yes 0. No: 1 Balance: 4000 Balance: 4500 -ATM- -ATM- 1. Withdraw 2. Deposit 1. Withdraw 2. Deposit 3. Transfer 3. Transfer 4. Check Balance 4. Check Balance 5. EXIT Choose operation: 2 Enter amount you want to deposit: 500 Check Balance? 1. Yes 0. No: 0 5. EXIT Choose operation: 3 Balance: 4500 *Note: The initial balance is 0. The user is given an option to check the balance or not. The program will run until the exit option is chosen.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY