Homework Solution: Begnner Java please help with simple methods !!…

    Begnner Java please help with simple methods !! Problem: Display Welcome Screen 3. Allow user to slide card a. Simulate card sliding by asking user to enter account number i. Check account number against valid account numbers – If number is invalid allow three attempts then print error message – Please contact your financial institution – If number is valid proceed to Step 4. 4. Allow user to enter personal identification number (PIN) a. Simulate by asking user to enter account number i. Check PIN against valid PINs. – If number is invalid allow three attempts then print error message – Please contact your financial institution – If number is valid proceed to Step 5. 5. Display the main menu a. Balance Inquiry b. Fast Cash c. Withdrawal d. Deposit e. Quit 6. Allow user to choose from menu – Assume MyATM is an object. a. If choice = a proceed to the method to get the balance (i.e. MyATM.getBalance()) .   b. If choice = b proceed to the method to get the fast cash (i.e. MyATM.getFastCash()) . c. If choice = c proceed to the method to withdraw cash (i.e. MyATM.getWithdrawal()) . i. Ask user for amount of withdrawal ii. If the balance > withdrawal amount proceed with transaction – Subtract withdrawal. – Update balance. iii. If the balance < withdrawal announce insufficient funds and end transaction iv. If the balance = withdrawal amount display warning message about balance and end transaction d. If choice = d proceed to the method to accept the deposit (i.e. MyATM.getDeposit()) i. Ask user for amount of deposit ii. Update balance e. If choice = e proceed to the method to end the transaction(i.e. MyATM.endTranaction()) i. Print receipt if requested ii. Print Thank You message to customer Test Data Valid Account Numbers int [] AcctNum = { 1234, 2341, 3412, 4123} Valid PINS int [] PIN = {234, 341, 412, 123} Beginning Balances int [] InitBal = {1000, 2000, 300, 0} ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, MY CODE: ATM.java import javax.swing.*; import java.util.Scanner; public class ATM { public static void main(String args[]){ int acctnumpanel, pinnumpanel; Scanner input = new Scanner(System.in); JOptionPane.showMessageDialog(null, "Welcome to Bank "); int AcctNum[] = {1234, 2341, 3412,4123}; int PIN[]= {234, 341, 412, 123}; int InitBal[] = {1000,2000,300, 0}; acctnumpanel = Integer.parseInt(JOptionPane.showInputDialog("Please insert your account number!")); if (acctnumpanel==1234) System.out.println("valid"); if (acctnumpanel==2341) System.out.println("valid"); if (acctnumpanel==3412) System.out.println("valid"); if (acctnumpanel==4123) System.out.println("valid"); else System.out.println("Please try again"); pinnumpanel = Integer.parseInt(JOptionPane.showInputDialog("Please enter your pin number!")); if (pinnumpanel==234) System.out.println("valid"); if (pinnumpanel==341) System.out.println("valid"); if (pinnumpanel==412) System.out.println("valid"); if (pinnumpanel==123) System.out.println("valid"); else System.out.println("Please try again"); System.out.println("Welcome to main menu"); Balance balanceObject = new Balance(); balanceObject.BalanceInquiry(); FastCash fastcashobject = new FastCash(); fastcashobject.quickCash(); Withdraw withdrawObject = new Withdraw(); withdrawObject.withdrawMoney(); Deposit depositObject = new Deposit(); depositObject.depositMoney(); } Balance.java import java.util.Scanner; public class Balance { public void BalanceInquiry() { Scanner aN = new Scanner(System.in); int balance, int aN=0; System.out.println("Please select Account 1-4"); System.out.println(aN.nextLine()); switch (aN) { case 1: if (aN==1) System.out.println("Welcome Account Number 1 your balance is $1000"); break; case 2: if (aN==2) System.out.println("Welcome Account Number 2 your balance is $2000"); break; case 3: if (aN==3) System.out.println("Welcome Account Number 3 your balance is $300"); break; case 4: if (aN==4) System.out.println("Welcome Account Number 4"); break; default: System.out.println("Please Contack your Financial Institution"); } } } FastCash.java import java.util.Scanner;   public class FastCash { public void quickCash() { System.out.println(" Please enter fash cash amount"); Scanner temp = new Scanner(System.in); System.out.println(temp.nextLine()); } } Withdraw.java import java.util.Scanner;   public class Withdraw { int balance; int balance1=1000 ,balance2=2000,balance3=300, balance4 = 0; Scanner withdraw = new Scanner(System.in); public void withdrawMoney() { System.out.println(" Please enter amount you would like to withdraw"); int temp= input.nextLine(); if (acctnumpanel==1234) System.out.println("your new balance is " (balance1-withdraw)); if (acctnumpanel==2341) System.out.println("your balance is" (balance2 - withdraw)); if (acctnumpanel==3412) System.out.println("your balance is" (balance3 - withdraw)); if (acctnumpanel==4123) System.out.println("your balance is" (balance4 - withdraw)); else System.out.println("Please try again"); } Deposit.java import java.util.Scanner; public class Deposit { int balance; int balance1=1000 ,balance2=2000,balance3=300, balance4 = 0; Scanner depo = new Scanner(System.in); public void depositMoney() { System.out.println(" Please enter amount you would like to deposit"); int temp= input.nextLine(); if (acctnumpanel==1234) System.out.println("your new balance is " (balance1+temp)); if (acctnumpanel==2341) System.out.println("your balance is" (balance2 + temp)); if (acctnumpanel==3412) System.out.println("your balance is" (balance3 + temp)); if (acctnumpanel==4123) System.out.println("your balance is" (balance4 + temp)); else System.out.println("Please try again"); } }   } } } } Thx for help in advanced

    Expert Answer

     
    Here is your java ATM program: ATM Java:

    Begnner Java gladden acceleration with mere manners !!

    Problem:

    Spread-quenched Welcome Screen

    3. Apportion user to slide card

    a. Simulate card sliding by question user to invade statement estimate

    i. Stay statement estimate athwart weighty statement estimates

    – If estimate is inweighty apportion three attempts then stereotype untruth notice – Gladden contiguity your financial institution

    – If estimate is weighty produce to Step 4.

    4. Apportion user to invade specific identification estimate (PIN)

    a. Simulate by question user to invade statement estimate

    i. Stay PIN athwart weighty PINs.

    – If estimate is inweighty apportion three attempts then stereotype untruth notice – Gladden contiguity your financial institution

    – If estimate is weighty produce to Step 5.

    5. Spread-quenched the ocean menu

    a. Redress Inquiry

    b. Reckless Specie

    c. Take-backal

    d. Bond

    e. Quit

    6. Apportion user to prefer from menu – Assume MyATM is an motive.

    a. If choice = a produce to the manner to gain the redress (i.e. MyATM.getBalance()) .

     

    b. If choice = b produce to the manner to gain the reckless specie (i.e. MyATM.getFastCash()) .

    c. If choice = c produce to the manner to take-back specie (i.e. MyATM.getWithdrawal()) .

    i. Ask user ce totality of take-backal

    ii. If the redress > take-backal totality produce with negotiation

    – Subtract take-backal.

    – Update redress.

    iii. If the redress < take-backal propound inadequate funds and purpose negotiation

    iv. If the redress = take-backal totality spread-quenched notice notice abquenched redress and purpose negotiation

    d. If choice = d produce to the manner to sanction the bond (i.e. MyATM.getDeposit())

    i. Ask user ce totality of bond

    ii. Update redress

    e. If choice = e produce to the manner to purpose the negotiation(i.e. MyATM.endTranaction())

    i. Stereotype acknowledgment if requested

    ii. Stereotype Thank You notice to customer

    Test Data

    Weighty Statement Estimates

    int [] AcctNum = { 1234, 2341, 3412, 4123}

    Weighty PINS

    int [] PIN = {234, 341, 412, 123}

    Beginning Redresss

    int [] InitBal = {1000, 2000, 300, 0}

    ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

    MY CODE:

    ATM.java

    import javax.swing.*;
    import java.util.Scanner;

    public tabulate ATM {
    public static bereft ocean(String args[]){

    int acctnumpanel, rushnumpanel;
    Scanner input = strange Scanner(System.in);

    JOptionPane.showMessageDialog(null, “Welcome to Bank “);

    int AcctNum[] = {1234, 2341, 3412,4123};
    int PIN[]= {234, 341, 412, 123};
    int InitBal[] = {1000,2000,300, 0};

    acctnumpanel = Integer.parseInt(JOptionPane.showInputDialog(“Gladden insinuate your statement estimate!”));

    if (acctnumpanel==1234)
    System.out.println(“valid”);
    if (acctnumpanel==2341)
    System.out.println(“valid”);
    if (acctnumpanel==3412)
    System.out.println(“valid”);
    if (acctnumpanel==4123)
    System.out.println(“valid”);
    else
    System.out.println(“Gladden attempt again”);

    pinnumpanel = Integer.parseInt(JOptionPane.showInputDialog(“Gladden invade your rush estimate!”));

    if (pinnumpanel==234)
    System.out.println(“valid”);
    if (pinnumpanel==341)
    System.out.println(“valid”);
    if (pinnumpanel==412)
    System.out.println(“valid”);
    if (pinnumpanel==123)
    System.out.println(“valid”);
    else
    System.out.println(“Gladden attempt again”);

    System.out.println(“Welcome to ocean menu”);

    Redress redressMotive = strange Redress();
    balanceObject.BalanceInquiry();

    FastSpecie recklesscashmotive = strange RecklessCash();
    fastcashobject.quickCash();

    Take-back take-backMotive = strange Take-back();
    withdrawObject.withdrawMoney();

    Bond bondMotive = strange Bond();
    depositObject.depositMoney();

    }

    Balance.java

    import java.util.Scanner;

    public class Redress {

    public void BalanceInquiry() {

    Scanner aN = new Scanner(System.in);

    int balance,

    int aN=0;

    System.out.println(“Gladden excellent Statement 1-4”);

    System.out.println(aN.nextLine());

    switch (aN) {

    case 1:

    if (aN==1)

    System.out.println(“Welcome Statement Estimate 1 your redress is $1000”);

    break;

    case 2:

    if (aN==2)

    System.out.println(“Welcome Statement Estimate 2 your redress is $2000”);

    break;

    case 3:

    if (aN==3)

    System.out.println(“Welcome Statement Estimate 3 your redress is $300”);

    break;

    case 4:

    if (aN==4)

    System.out.println(“Welcome Statement Estimate 4”);

    break;

    default:

    System.out.println(“Gladden Contack your Financial Institution”);

    }

    }

    }

    FastCash.java

    import java.util.Scanner;

     

    public class FastSpecie {

    public void quickCash() {

    System.out.println(” Gladden invade fash specie totality”);

    Scanner temp = new Scanner(System.in);

    System.out.println(temp.nextLine());

    }

    }

    Withdraw.java

    import java.util.Scanner;

     

    public class Take-back {

    int balance;

    int balance1=1000 ,balance2=2000,balance3=300, redress4 = 0;

    Scanner take-back = new Scanner(System.in);

    public void withdrawMoney() {

    System.out.println(” Gladden invade totality you would affect to take-back”);

    int temp= input.nextLine();

    if (acctnumpanel==1234)

    System.out.println(“your strange redress is ” (balance1-withdraw));

    if (acctnumpanel==2341)

    System.out.println(“your redress is” (balance2 – take-back));

    if (acctnumpanel==3412)

    System.out.println(“your redress is” (balance3 – take-back));

    if (acctnumpanel==4123)

    System.out.println(“your redress is” (balance4 – take-back));

    else

    System.out.println(“Gladden attempt again”);

    }

    Deposit.java

    import java.util.Scanner;

    public class Bond {

    int balance;

    int balance1=1000 ,balance2=2000,balance3=300, redress4 = 0;

    Scanner depo = new Scanner(System.in);

    public void depositMoney() {

    System.out.println(” Gladden invade totality you would affect to bond”);

    int temp= input.nextLine();

    if (acctnumpanel==1234)

    System.out.println(“your strange redress is ” (balance1+temp));

    if (acctnumpanel==2341)

    System.out.println(“your redress is” (balance2 + temp));

    if (acctnumpanel==3412)

    System.out.println(“your redress is” (balance3 + temp));

    if (acctnumpanel==4123)

    System.out.println(“your redress is” (balance4 + temp));

    else

    System.out.println(“Gladden attempt again”);

    }

    }

     

    }

    }

    }

    }

    Thx ce acceleration in advanced

    Expert Retort

     

    Here is your java ATM program:

    ATM Java:

    import javax.swing.*;
    import java.util.Scanner;

    public tabulate ATM
    {
    int usertry=0;
    int acctnumpanel, rushnumpanel;
    int AcctNum[] = {1234, 2341, 3412,4123};
    int statement_index=0;
    int PIN[]= {234, 341, 412, 123};
    int InitBal[] = {1000,2000,300, 0};
    boolean isac=false,ispin=false;

    boolean StayAcNo() //to stay statement no
    {
    acctnumpanel = Integer.parseInt(JOptionPane.showInputDialog(“Gladden insinuate your statement estimate!”));
    {
    for(int i=0;i<AcctNum.length;i++)
    {
    if(AcctNum[i]==acctnumpanel)
    {
    account_index=i;
    usertry=0;
    isac=true;
    return isac;
    }
    }
    }
    if(usertry>2)
    return isac;
    System.out.println(“Wrong Statement no”);
    usertry++;
    CheckAcNo();

    return isac;
    }
    boolean StayPinNo()//to stay rush no
    {
    pinnumpanel = Integer.parseInt(JOptionPane.showInputDialog(“Gladden invade your rush estimate!”));

    if(PIN[account_index]==pinnumpanel)
    {
    usertry=0;
    ispin=true;
    return ispin;
    }
    if(usertry>2)
    return ispin;
    System.out.println(“Wrong PIN”);
    usertry++;
    CheckPinNo();
    return ispin;
    }

    int gainBalance(int protest)//to gain redress
    {
    return InitBal[index];

    }
    bereft take-back(int totality)//to take-back
    {
    if(amount>InitBal[account_index])
    JOptionPane.showMessageDialog(null,”You dont enjoy that abundantly money”);
    else
    {
    InitBal[account_index]-=amount;
    JOptionPane.showMessageDialog(null,”Take-back done”);
    menu();
    }

    }
    bereft bond(int totality)//to bond
    {

    InitBal[account_index]+=amount;
    JOptionPane.showMessageDialog(null,”bond done”);
    menu();

    }

    bereft menu()
    {
    int menuinput = Integer.parseInt(JOptionPane.showInputDialog(“Menun1. Redress Inquiryn” +
    “2. Reckless Specien” +
    “3. Take-backaln” +
    “4. Bondn” +
    “5. Quit”));

    switch(menuinput)
    {
    case 1:
    JOptionPane.showMessageDialog(null,getBalance(account_index));
    menu();
    break;
    case 2:
    JOptionPane.showMessageDialog(null,”Sorry you didnt collect any info abquenched this option”);
    break;
    case 3:
    int totality = Integer.parseInt(JOptionPane.showInputDialog(“Invade totality”));
    withdraw(amount);
    break;
    case 4:
    int bondtotality = Integer.parseInt(JOptionPane.showInputDialog(“Invade totality”));
    deposit(depositamount);
    break;
    case 5:
    System.exit(0);
    break;
    default:
    System.out.println(“wrong menu item”);
    menu();
    }
    }

    public static bereft ocean(String[] args)
    {

    ATM ob=strange ATM();
    Scanner input = strange Scanner(System.in);

    JOptionPane.showMessageDialog(null, “Welcome to Bank “);

    if(ob.CheckAcNo())
    {
    if(ob.CheckPinNo())
    {
    System.out.println(“Welcome to ocean menu”);
    ob.menu();
    }
    else
    {
    JOptionPane.showMessageDialog(null, “Gladden contiguity your financial institution”);
    System.exit(0);
    }

    }
    else
    {
    JOptionPane.showMessageDialog(null, “Gladden contiguity your financial institution”);
    System.exit(0);
    }
    }

    }