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 artless orders !!

    Problem:

    Parade Welcome Screen

    3. Sanction user to slide card

    a. Simulate card sliding by investigation user to invade statement sum

    i. Obstruct statement sum opposite available statement sums

    – If sum is inavailable sanction three attempts then sculpture deception communication – Gladden touch your financial institution

    – If sum is available acknowledgments to Step 4.

    4. Sanction user to invade separate identification sum (PIN)

    a. Simulate by investigation user to invade statement sum

    i. Obstruct PIN opposite available PINs.

    – If sum is inavailable sanction three attempts then sculpture deception communication – Gladden touch your financial institution

    – If sum is available acknowledgments to Step 5.

    5. Parade the deep menu

    a. Redress Inquiry

    b. Steadfast Currency

    c. Retreatal

    d. Protection

    e. Quit

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

    a. If choice = a receipts to the order to attain the redress (i.e. MyATM.getBalance()) .

     

    b. If choice = b receipts to the order to attain the steadsteadfast currency (i.e. MyATM.getFastCash()) .

    c. If choice = c receipts to the order to retreat currency (i.e. MyATM.getWithdrawal()) .

    i. Ask user coercion sum of retreatal

    ii. If the redress > retreatal sum acknowledgments with business

    – Subtract retreatal.

    – Update redress.

    iii. If the redress < retreatal promulgate inadequate funds and purpose business

    iv. If the redress = retreatal sum parade premonition communication abextinguished redress and purpose business

    d. If choice = d receipts to the order to sanction the protection (i.e. MyATM.getDeposit())

    i. Ask user coercion sum of protection

    ii. Update redress

    e. If choice = e receipts to the order to purpose the business(i.e. MyATM.endTranaction())

    i. Sculpture acknowledgment if requested

    ii. Sculpture Thank You communication to customer

    Test Data

    Available Statement Sums

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

    Available 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 adjust ATM {
    public static unsubstantial deep(String args[]){

    int acctnumpanel, nothingnumpanel;
    Scanner input = strangelightlight 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 suggest your statement sum!”));

    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 test again”);

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

    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 test again”);

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

    Redress redressDesign = strangelightlight Redress();
    balanceObject.BalanceInquiry();

    FastCurrency steadfastcashdesign = strangelightlight SteadfastCash();
    fastcashobject.quickCash();

    Retreat retreatDesign = strangelightlight Retreat();
    withdrawObject.withdrawMoney();

    Protection protectionDesign = strangelightlight Protection();
    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 Sum 1 your redress is $1000”);

    break;

    case 2:

    if (aN==2)

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

    break;

    case 3:

    if (aN==3)

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

    break;

    case 4:

    if (aN==4)

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

    break;

    default:

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

    }

    }

    }

    FastCash.java

    import java.util.Scanner;

     

    public class FastCurrency {

    public void quickCash() {

    System.out.println(” Gladden invade fash currency sum”);

    Scanner temp = new Scanner(System.in);

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

    }

    }

    Withdraw.java

    import java.util.Scanner;

     

    public class Retreat {

    int balance;

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

    Scanner retreat = new Scanner(System.in);

    public void withdrawMoney() {

    System.out.println(” Gladden invade sum you would approve to retreat”);

    int temp= input.nextLine();

    if (acctnumpanel==1234)

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

    if (acctnumpanel==2341)

    System.out.println(“your redress is” (balance2 – retreat));

    if (acctnumpanel==3412)

    System.out.println(“your redress is” (balance3 – retreat));

    if (acctnumpanel==4123)

    System.out.println(“your redress is” (balance4 – retreat));

    else

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

    }

    Deposit.java

    import java.util.Scanner;

    public class Protection {

    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 sum you would approve to protection”);

    int temp= input.nextLine();

    if (acctnumpanel==1234)

    System.out.println(“your strangelightlight 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 test again”);

    }

    }

     

    }

    }

    }

    }

    Thx coercion acceleration in advanced

    Expert Reply

     

    Here is your java ATM program:

    ATM Java:

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

    public adjust ATM
    {
    int usertry=0;
    int acctnumpanel, nothingnumpanel;
    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 ObstructAcNo() //to obstruct statement no
    {
    acctnumpanel = Integer.parseInt(JOptionPane.showInputDialog(“Gladden suggest your statement sum!”));
    {
    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 ObstructPinNo()//to obstruct nothing no
    {
    pinnumpanel = Integer.parseInt(JOptionPane.showInputDialog(“Gladden invade your nothing sum!”));

    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 attainBalance(int refutation)//to attain redress
    {
    return InitBal[index];

    }
    unsubstantial retreat(int sum)//to retreat
    {
    if(amount>InitBal[account_index])
    JOptionPane.showMessageDialog(null,”You dont accept that ample money”);
    else
    {
    InitBal[account_index]-=amount;
    JOptionPane.showMessageDialog(null,”Retreat done”);
    menu();
    }

    }
    unsubstantial protection(int sum)//to protection
    {

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

    }

    unsubstantial menu()
    {
    int menuinput = Integer.parseInt(JOptionPane.showInputDialog(“Menun1. Redress Inquiryn” +
    “2. Steadfast Currencyn” +
    “3. Retreataln” +
    “4. Protectionn” +
    “5. Quit”));

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

    public static unsubstantial deep(String[] args)
    {

    ATM ob=newlight ATM();
    Scanner input = strangelightlight Scanner(System.in);

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

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

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

    }