Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In java, The client wants a GUI for its virtual ATM. The program will allow a us

ID: 3833743 • Letter: I

Question

In java,

The client wants a GUI for its virtual ATM. The program will allow a user to enter their personal pin number (only 4 numbers allowed from 0001 to 9999). The user then must choose which account they would like to make a transaction: Savings Account or Checking Account, or Loan Payment (such as a mortgage, a car loan, or a student loan). If the user chooses a savings account, then the allowed transactions are either to add money to the saving account or to withdraw money from the savings account. A balance must be given to the user at the end of the transaction. Assume that the user has a starting balance of $4000 in each of their checking and savings accounts. Error trapping: if a balance goes below $200, then an alert to the user will be issued.

Explanation / Answer

This Virtual Atm program will add, withdraw and displays the balance. I have used switch case to execute one statement from multiple statements. If user the wrong option system exists. In the program do while loop is used to make an another transcation or not. If user clicks yes do loop continues, otherwise atm exists. Hope this helps,

package virtualatm;
import javax.swing.JOptionPane;
public class VirtualATM {
    public static void main(String[] args) {
    //items and balances
    int SaveBalance=4000;
    int CheckBalance=4000;
    int MortBalance = 0, StudBalance = 0, AutoBalance = 0, PersBalance = 0;
    int pas, wid, dep;
    int num;
    int Snum, Swid, Sdep = 0;
    int Cnum, Cwid = 0, Cdep;
    int Lnum;
    int back;
    int pass = 0;
    //welcome to atm
        JOptionPane.showMessageDialog(null, "Welcome to My ATM","ATM",
                JOptionPane.INFORMATION_MESSAGE);
        //pin
        pass=Integer.parseInt(JOptionPane.showInputDialog(null, "Please Enter Your Four Digit Pin","ATM",
        JOptionPane.QUESTION_MESSAGE));
        //input pin
     
        if ( pass < 10000 && pass > 0000){
         
            //if pin is correct
            do{
                //choose account
                String f=JOptionPane.showInputDialog(null,"Please Choose Your Account "+"[1] Checking Account "
        +"[2] Savings Account "+"[3] Loans ", "MyBank",JOptionPane.QUESTION_MESSAGE);              
                num=Integer.parseInt(f);
              
                switch(num){
                //Checking account
                    case 1:
                    String g=JOptionPane.showInputDialog(null,"Please Choose Your Transaction "+"[1] Check Balance "
                            +"[2] Withdraw "+"[3] Deposit ", "MyBank",JOptionPane.QUESTION_MESSAGE);
                     Cnum=Integer.parseInt(g);
                     if (Cnum==1){
                        JOptionPane.showMessageDialog(null,"Your Balance is "+CheckBalance+" dollars","ATM",JOptionPane.INFORMATION_MESSAGE);
                        }
                         if (Cnum==2){
                        Cwid=Integer.parseInt(JOptionPane.showInputDialog(null,"Please Enter Amount to Withdraw "
                                ,"ATM",JOptionPane.INFORMATION_MESSAGE));
                        if(CheckBalance==200){
                                JOptionPane.showMessageDialog(null,"Your Balance is below 200","ATM",JOptionPane.ERROR_MESSAGE);}
                        if (Cwid>CheckBalance){
                            JOptionPane.showMessageDialog(null,"Insufficient Funds!","ATM",JOptionPane.ERROR_MESSAGE);
                        }
                        CheckBalance=CheckBalance-Cwid;
                        JOptionPane.showMessageDialog(null,"Please collect your money"+" "+"Your Remaining Balance is"+CheckBalance,"ATM",JOptionPane.INFORMATION_MESSAGE);
                        if(CheckBalance<200){
                                JOptionPane.showMessageDialog(null,"Your Balance is below 200.Please maintain minimum balance","ATM",JOptionPane.ERROR_MESSAGE);}
            
                      
                         }
                      
                        if (Cnum == 3){
                            Cdep=Integer.parseInt(JOptionPane.showInputDialog(null,"Please Enter Amount to Deposit ",
                                    "ATM",JOptionPane.INFORMATION_MESSAGE));
                            CheckBalance=Cdep+CheckBalance;
                            JOptionPane.showMessageDialog(null,"Your Current Balance is"+CheckBalance,"ATM",JOptionPane.INFORMATION_MESSAGE);
                        }
                        break;
              
                //Savings account
                    case 2:
                    String h=JOptionPane.showInputDialog(null,"Please Choose Your Transaction "+"[1] Check Balance "
                            +"[2] Withdraw "+"[3] Deposit ", "MyBank",JOptionPane.QUESTION_MESSAGE);
                    Snum=Integer.parseInt(h);
                    if (Snum==1){
                        JOptionPane.showMessageDialog(null,"Your Balance is "+SaveBalance+" dollars","ATM",JOptionPane.INFORMATION_MESSAGE);
                        }
                    if (Snum==2){
                        Swid=Integer.parseInt(JOptionPane.showInputDialog(null,"Please Enter Amount to Withdraw "
                                ,"ATM",JOptionPane.INFORMATION_MESSAGE));
                        if (Swid>SaveBalance){
                            JOptionPane.showMessageDialog(null,"Insufficient Funds!","ATM",JOptionPane.ERROR_MESSAGE);
                        }
                        else{
                            SaveBalance=CheckBalance-Swid;
                            JOptionPane.showMessageDialog(null,"Your Remaining Balance is"+SaveBalance,"ATM",JOptionPane.INFORMATION_MESSAGE);
                        }
                        if (Snum == 3){
                            dep=Integer.parseInt(JOptionPane.showInputDialog(null,"Please Enter Amount to Deposit ",
                                    "ATM",JOptionPane.INFORMATION_MESSAGE));
                            SaveBalance=Sdep+SaveBalance;
                            JOptionPane.showMessageDialog(null,"Your Current Balance is"+SaveBalance,"ATM",JOptionPane.INFORMATION_MESSAGE);
                        }       
                }
                        break;
                    //Loans
                    case 3:
                    String i=JOptionPane.showInputDialog(null,"Please Choose the Loan you would like to make a payment on "+"[1] Mortgage "
                            +"[2] Student Loan "+"[3] Auto Loan " + "[4] Personal Loan ", "MyBank",JOptionPane.QUESTION_MESSAGE);
                    Lnum=Integer.parseInt(i);
                    if (Lnum==1)
                    {
                        JOptionPane.showMessageDialog(null,"Your Current Balance is "+MortBalance+" dollars","ATM",JOptionPane.INFORMATION_MESSAGE);
                        MortBalance=MortBalance-3500;
                        JOptionPane.showMessageDialog(null,"Your remaing Mortgage loan is "+Math.abs(MortBalance),"ATM",JOptionPane.INFORMATION_MESSAGE);
                    }
                    if (Lnum==2)
                    {
                        JOptionPane.showMessageDialog(null,"Your Current Balance is "+StudBalance+" dollars","ATM",JOptionPane.INFORMATION_MESSAGE);
                        StudBalance=StudBalance-250;
                        JOptionPane.showMessageDialog(null,"Your Student loan have to be paid is"+Math.abs(StudBalance),"ATM",JOptionPane.INFORMATION_MESSAGE);
                    }       
                    if (Lnum==3)
                    {
                        JOptionPane.showMessageDialog(null,"Your Current Balance is "+AutoBalance+" dollars","ATM",JOptionPane.INFORMATION_MESSAGE);
                        AutoBalance=AutoBalance-500;
                        JOptionPane.showMessageDialog(null,"Your Auto loan have to paid is "+Math.abs(AutoBalance),"ATM",JOptionPane.INFORMATION_MESSAGE);
                    }
                    if (Lnum==4)
                    {
                        JOptionPane.showMessageDialog(null,"Your Current Balance is "+PersBalance+" dollars","ATM",JOptionPane.INFORMATION_MESSAGE);
                        PersBalance=PersBalance-1000;
                        JOptionPane.showMessageDialog(null,"Your Personal loan have to be paid is "+Math.abs(PersBalance),"ATM",JOptionPane.INFORMATION_MESSAGE);
                    }
                        break;
                    default:System.exit(0);
                }
        
                //Return to top
                back=JOptionPane.showConfirmDialog(null,"Would you like to make another transaction","ATM",JOptionPane.YES_NO_OPTION);
        }    while(back==0);
      
    }
        //End if
        //incorrect pin
     
        else{
          JOptionPane.showMessageDialog(null,"Please re-enter PIN","Incorrect PIN",JOptionPane.ERROR_MESSAGE);     
       }
}}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote