Question

Question #1 Write a javascript for an ATM withdrawal application. The ATM machine will only accept a transaction if the withdrawal amount X is a multiple of 20, and account has enough balance to perform withdrawal transaction (including bank charges) For each successful withdrawal the bank charges 0.50$. The account will have an initial balance of 500$. A) You have to declare an input type and a button in your HTML form with input type having a placeholder Enter withdrwal amount Submit B) Javascript has 2 functions validateAmount.js and withdrwawAmount.js a. validateAmount: Make sure the amount entered is numeric, alert a message Please enter numeric value otherwise. b. withdrawAmount: Process transaction and alert one of the following three messages depending on the withdrawal amount i. Not multiple of 20: Incorrect withdrawal amount ii. Insufficient funds iii. Successful transaction! \n Current Balance is: ” + balance

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is code:

atm.html:

<!doctype html>

<html>

<head>

<script src="./validateAmount.js"></script>

<script src="./withdrwawAmount.js"></script>

<title>ATM</title>

</head>

<body>

<div style="text-align: center">

<input type="text" id="txtAmount" placeholder="Enter withdrawal amount">

<button onclick="withdrawal()">Submit</button>

</div>

</body>

</html>

validateAmount.js:

function validate(amount) {

var re = /[+-]?([0-9]*[.])?[0-9]+/;

return re.test(amount);

}

withdrwawAmount.js:

var balance = 500;

function withdrawal() {

var input = document.getElementById("txtAmount").value;

if (validate(input)) { // check if input is value

var amount = Number(input);

if (amount % 20 != 0) { // check if divisible by 20

alert("Incorrect withdrawal amount");

} else if (amount > window.balance) { // check if sufficient balance

alert("Insufficient funds");

} else {

// deduct amount

window.balance = window.balance - amount;

alert("Successful transaction!\n Current Balance is : " + window.balance)

}

} else {

alert("Please enter numeric value");

}

}

Output:

Successful transaction! Current Balance is: 400 OK

Add a comment
Know the answer?
Add Answer to:
Question #1 Write a javascript for an ATM withdrawal application. The ATM machine will only accept...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • BANK ATM application program in JAVASCRIPT, that allows the user to manage transaction data. like withdraw,deposit,etc....

    BANK ATM application program in JAVASCRIPT, that allows the user to manage transaction data. like withdraw,deposit,etc. Make sure it produces tabular feedback to the user. (meaning user should be able to enter a quanity let's say $20 withdrawal and balance of $100, so it's balance will be $80..As well to deposit money and add the balance to that deposit. Finally to show (-) signs if balance is overdraw,,,Program reads input from the user though the web page., any help is...

  • You are to write a Java program using the following instructions to build a bank-ATM server...

    You are to write a Java program using the following instructions to build a bank-ATM server system with sockets. A bank holds accounts that can have deposits, withdrawals, or retrievals of balance. The bank server provides the account for transactions when a client uses and ATM machine. The ATM asks for the type of transaction and the amount (if needed), then creates a socket connection to the bank to send the transaction for processing. The bank performs the transaction on...

  • use the following steps to develop a flow chart algorithm? Step Description Your Microsoft Excel Macro-Enabled...

    use the following steps to develop a flow chart algorithm? Step Description Your Microsoft Excel Macro-Enabled ExcelBank ATM Mark Step 1 Insert        ATM Card A ‘Welcome to ExcelBank ATM’ dialog box with a ‘Start’ button ½ Step 2 Select Language An Input Box / List Box / Check Box lists the 11 South African official languages (English is number 1) and requests the patron to enter his/her preferred language. The ATM will only proceed to the next step when...

  • How to make all the buttons work using javascript? <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta...

    How to make all the buttons work using javascript? <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> function openAccount() { /* - get the account and initial amount values - check that all necessary information is provided - call the setCookie function to create account */ } function Deposit() { /* - get the account and amount values - check that all necessary information is provided - alter cookie with current amount of deposit */ } function...

  • You will create an HTML file that contains input elements with event-handling capabilities according to the...

    You will create an HTML file that contains input elements with event-handling capabilities according to the requirements listed on the next page. The program that processed the Banking Transactions in the previous assignment needs a makeover to accept data using text boxes. The results will be displayed on the same rows that contain the transactions. (Balance, Deposit, Withdrawal). The requirements for calculating the final balances and producing special messages (if applicable) remain unchanged. However, the initial balance will not be...

  • I am trying to create a ATM style bank program that accept the customer id ,...

    I am trying to create a ATM style bank program that accept the customer id , in the welcoming panel ,but how do i make when the customer input their id# and click on the ok button then they have 3 or so tries to input the correct id# and if successful then send to the other panel where they choose which transaction to they want to make for example savings , checking account , make and deposit , and...

  • Using Javascript, I have two radio buttons, depending on the value of the radio button 1...

    Using Javascript, I have two radio buttons, depending on the value of the radio button 1 or 2, you will send a different form to the user. So, if radio button is value "1" send new form1 or if value "2" send new form 2.  New form will ask for letter grades for four courses in textboxes. Onsubmit of new form letter grades A,B,C,D need to be changed to numeric values 1,2,3,4 so an average grade for the four couses can...

  • Write a program called problem4.cpp to implement an automatic teller machine (ATM) following the BankAccount class...

    Write a program called problem4.cpp to implement an automatic teller machine (ATM) following the BankAccount class the we implemented in class. Your main program should initialize a list of accounts with the following values and store them in an array Account 101 → balance = 100, interest = 10% Account 201 → balance = 50, interest = 20% Account 108 → balance = 200, interest = 11% Account 302 → balance = 10, interest = 5% Account 204 → balance...

  • how can i code this only using a textbox for results Create Windows Forms applications called...

    how can i code this only using a textbox for results Create Windows Forms applications called ATM Project that allows the customer to deposit the initial amount and enter the amount to be withdrawn. You need to display the total amount in the account, dispenses the money to the customer, and debits the account by the amount withdrawn including any service charges. The ATM allows a customer to withdraw a maximum of $500 per transition in $20 increments. If a...

  • i'm having trouble with 1 and 3 using html, javascript and jquery 1) Change the "Search"...

    i'm having trouble with 1 and 3 using html, javascript and jquery 1) Change the "Search" link on the left to a button that when clicked, hide all the fields on the form and display the text "This is a search feature..." 3) When the user fills the form and clicks "Login", the values inputted should be displayed in the empty row (under Login) of the page. The display should be in the form: Student ID: <input value> Student Name:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT