Barryj Barryj - 16 days ago
89 0

asdasda

Javascript

lkangdoiugbpas

<script>
// my bank savings
// Date created 

//initialise
var balance=0;
var userinput='';

//main program
document.write('My Bank savings<BR>');
document.write('=====================<BR>');
document.write('A. Add money<BR>');
document.write('W. Withdrawal money<BR>');
document.write('B. Balance<BR>');
document.write('Q. Quit<BR>');
while(userinput!='Q')
{
  userinput=prompt('Enter option (A,W,B or Q)','Q');
  
  // ********** display balance ******************
  if(userinput=='B')
    {
    alert('You have saved = ' + balance);
    }  
  
  // ********** make a deposit *******************
  if(userinput=='A')
    {
    var payment=eval(prompt('Enter money to deposit'));
    balance=balance+payment
    }

  //************ Make withdrawal ***************
  if(userinput=='W')
  {
  var withdrawal=eval(prompt('Enter withdrawal amount'));
  if else (withdrawal >= balance)
  alert ('Not enough balance');
  balance=balance-withdrawal
  }
}

</script>
Comments