Ask Question
5 April, 04:30

1) Your program must contain functions to: deposit, withdraw, balance inquiry and quit. 2) Based on the selection made by the user the functions must be called with the following criteria: a. A user can deposit any amount of money in their account. The function must display the new balance after depositing. by. A person can withdraw an amount as long as it is lower than or equal to his current balance. The function must also display a warning if the new balance is below $100. Must not allow the user to withdraw if amount is great than current balance. Before this function ends - the new balance must be displayed. c. Balance inquiry function must display the balance.

+1
Answers (1)
  1. 5 April, 07:47
    0
    import java. util. Scanner;

    public class num6 {

    static double balance = 10000.5; / /Current Balance

    //The main Method

    public static void main (String[] args) {

    //Request User Input

    System. out. println ("Enter 1 for deposit / nEnter 2 for Withdraw/nEnter 3 for Balance Enquiry/n0 to quit ");

    Scanner in = new Scanner (System. in);

    int op = in. nextInt ();

    //Check to determine the Operation the user wants

    if (op = = 1) {

    System. out. println ("Enter amount to deposit");

    double depositeAmount = in. nextDouble ();

    deposit (depositeAmount); / /Call the deposit method

    }

    if (op = = 2) {

    System. out. println ("Enter amount to Withdraw");

    double withdrawAmount = in. nextDouble ();

    //validate the withdraw amount

    if (withdrawAmount > balance) {

    System. out. println ("Insuffucient fund");

    System. out. println ("Your current balance is "+balance);

    }

    else {

    withdraw (withdrawAmount); //Call withdraw Method

    }

    }

    if (op = = 3) {

    balanceEnquiry ();

    }

    }

    //Deposit Method

    public static double deposit (double depositAmount) {

    double newBalance = balance + depositAmount;

    System. out. println ("You deposited "+depositAmount+"Your new balance is "+newBalance);

    return newBalance;

    }

    //Withdraw Method

    public static double withdraw (double withdrawAmount) {

    double newBalance = balance - withdrawAmount;

    System. out. println ("You Withdrew "+withdrawAmount+"Your new balance is "+newBalance);

    if (newBalance < 100) {

    System. out. println ("Your Balance is low");

    }

    return newBalance;

    }

    //Balance Enquiry Method

    public static void balanceEnquiry () {

    System. out. println ("Your current balance is "+balance);

    }

    }

    Explanation:

    This is solved in Java programming language

    See code explation provided as comments
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “1) Your program must contain functions to: deposit, withdraw, balance inquiry and quit. 2) Based on the selection made by the user the ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers