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 content aid with unartificial courses !!

    Problem:

    Parade Welcome Screen

    3. Sanction user to slide card

    a. Simulate card sliding by interrogation user to penetrate statement enumerate

    i. Repress statement enumerate counter sound statement enumerates

    – If enumerate is insound sanction three attempts then sculpture hallucination communication – Content adjunction your financial institution

    – If enumerate is sound avail to Step 4.

    4. Sanction user to penetrate peculiar identification enumerate (PIN)

    a. Simulate by interrogation user to penetrate statement enumerate

    i. Repress PIN counter sound PINs.

    – If enumerate is insound sanction three attempts then sculpture hallucination communication – Content adjunction your financial institution

    – If enumerate is sound avail to Step 5.

    5. Parade the ocean menu

    a. Poise Inquiry

    b. Firm Currency

    c. Wrestal

    d. Safety

    e. Quit

    6. Sanction user to cull from menu – Assume MyATM is an view.

    a. If choice = a avail to the course to procure the poise (i.e. MyATM.getBalance()) .

     

    b. If choice = b avail to the course to procure the firm currency (i.e. MyATM.getFastCash()) .

    c. If choice = c avail to the course to wrest currency (i.e. MyATM.getWithdrawal()) .

    i. Ask user restraint whole of wrestal

    ii. If the poise > wrestal whole avail with occurrence

    – Subtract wrestal.

    – Update poise.

    iii. If the poise < wrestal promulgate inadequate funds and purpose occurrence

    iv. If the poise = wrestal whole parade caution communication encircling poise and purpose occurrence

    d. If choice = d avail to the course to sanction the safety (i.e. MyATM.getDeposit())

    i. Ask user restraint whole of safety

    ii. Update poise

    e. If choice = e avail to the course to purpose the occurrence(i.e. MyATM.endTranaction())

    i. Sculpture acknowledgment if requested

    ii. Sculpture Thank You communication to customer

    Test Data

    Sound Statement Enumerates

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

    Sound PINS

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

    Beginning Poises

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

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

    MY CODE:

    ATM.java

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

    public assort ATM {
    public static invalid ocean(String args[]){

    int acctnumpanel, buttonnumpanel;
    Scanner input = odd 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(“Content insinuate your statement enumerate!”));

    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(“Content aim again”);

    pinnumpanel = Integer.parseInt(JOptionPane.showInputDialog(“Content penetrate your button enumerate!”));

    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(“Content aim again”);

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

    Poise poiseView = odd Poise();
    balanceObject.BalanceInquiry();

    FastCurrency firmcashview = odd FirmCash();
    fastcashobject.quickCash();

    Wrest wrestView = odd Wrest();
    withdrawObject.withdrawMoney();

    Safety safetyView = odd Safety();
    depositObject.depositMoney();

    }

    Balance.java

    import java.util.Scanner;

    public class Poise {

    public void BalanceInquiry() {

    Scanner aN = new Scanner(System.in);

    int balance,

    int aN=0;

    System.out.println(“Content picked Statement 1-4”);

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

    switch (aN) {

    case 1:

    if (aN==1)

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

    break;

    case 2:

    if (aN==2)

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

    break;

    case 3:

    if (aN==3)

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

    break;

    case 4:

    if (aN==4)

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

    break;

    default:

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

    }

    }

    }

    FastCash.java

    import java.util.Scanner;

     

    public class FastCurrency {

    public void quickCash() {

    System.out.println(” Content penetrate fash currency whole”);

    Scanner temp = new Scanner(System.in);

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

    }

    }

    Withdraw.java

    import java.util.Scanner;

     

    public class Wrest {

    int balance;

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

    Scanner wrest = new Scanner(System.in);

    public void withdrawMoney() {

    System.out.println(” Content penetrate whole you would affect to wrest”);

    int temp= input.nextLine();

    if (acctnumpanel==1234)

    System.out.println(“your odd poise is ” (balance1-withdraw));

    if (acctnumpanel==2341)

    System.out.println(“your poise is” (balance2 – wrest));

    if (acctnumpanel==3412)

    System.out.println(“your poise is” (balance3 – wrest));

    if (acctnumpanel==4123)

    System.out.println(“your poise is” (balance4 – wrest));

    else

    System.out.println(“Content aim again”);

    }

    Deposit.java

    import java.util.Scanner;

    public class Safety {

    int balance;

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

    Scanner depo = new Scanner(System.in);

    public void depositMoney() {

    System.out.println(” Content penetrate whole you would affect to safety”);

    int temp= input.nextLine();

    if (acctnumpanel==1234)

    System.out.println(“your odd poise is ” (balance1+temp));

    if (acctnumpanel==2341)

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

    if (acctnumpanel==3412)

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

    if (acctnumpanel==4123)

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

    else

    System.out.println(“Content aim again”);

    }

    }

     

    }

    }

    }

    }

    Thx restraint aid in advanced

    Expert Rejoinder

     

    Here is your java ATM program:

    ATM Java:

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

    public assort ATM
    {
    int usertry=0;
    int acctnumpanel, buttonnumpanel;
    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 RepressAcNo() //to repress statement no
    {
    acctnumpanel = Integer.parseInt(JOptionPane.showInputDialog(“Content insinuate your statement enumerate!”));
    {
    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 RepressPinNo()//to repress button no
    {
    pinnumpanel = Integer.parseInt(JOptionPane.showInputDialog(“Content penetrate your button enumerate!”));

    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 procureBalance(int apostacy)//to procure poise
    {
    return InitBal[index];

    }
    invalid wrest(int whole)//to wrest
    {
    if(amount>InitBal[account_index])
    JOptionPane.showMessageDialog(null,”You dont entertain that greatly money”);
    else
    {
    InitBal[account_index]-=amount;
    JOptionPane.showMessageDialog(null,”Wrest done”);
    menu();
    }

    }
    invalid safety(int whole)//to safety
    {

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

    }

    invalid menu()
    {
    int menuinput = Integer.parseInt(JOptionPane.showInputDialog(“Menun1. Poise Inquiryn” +
    “2. Firm Currencyn” +
    “3. Wrestaln” +
    “4. Safetyn” +
    “5. Quit”));

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

    public static invalid ocean(String[] args)
    {

    ATM ob=odd ATM();
    Scanner input = odd 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, “Content adjunction your financial institution”);
    System.exit(0);
    }

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

    }