JavaScript Project – Banking Application

Free Web development courses with real-time projects Start Now!!

Program 1

class Account
{
           constructor(accountid,accountname,amount=0)
           {
              this.accountid=accountid
              this.accountname=accountname
              this.amount=amount
           }
           withd(amount)
           { 
              
                if(amount>this.amount)     
                   console.log("Invalid amount...")
                else
                  this.amount=this.amount-amount
             }  
           deposit(amount)
           {
                      this.amount=this.amount+amount 
           }
           showBalance()
           {
                 console.log("Account Number: " + this.accountid)
                 console.log("Name: " + this.accountname)
                 console.log("Current balance: " + this.amount)
           }
}




"use strict"
const ps=require("prompt-sync")
const prompt=ps({sigint:true})
let choice
let amt
let pin =parseInt(prompt("Enter Your password : "))
if(pin===1234)
{
    A1=new Account(101,"Vishal Sharma",5000)  
do
{
     console.log("--------------------Bank Application----------------------")
     console.log("                    1. Withdrawal")
     console.log("                    2. Deposit")
     console.log("                    3. Check Balance ")
     console.log("                    4. Exit ")
     console.log("--------------------------------------------------------------")

         choice=parseInt(prompt("Enter Your choice : "))
      switch(choice)
    {
      case 1: 
    {
        amt=parseInt(prompt("Enter Amount for withdrawal: "))
        A1.withd(amt)
        A1.showBalance()
        break
    }
   case 2:
   { 
    amt=parseInt(prompt("Enter Amount for deposit: "))
    A1.deposit(amt)
    A1.showBalance()
    break
   }
   case 3:
    {
       A1.showBalance()
       break
    }   
     case 4:break 
    default :console.log("Invalid choice......")         
}
}while(choice!=4)
}
else
console.log("Invalid password ")

 

We work very hard to provide you quality material
Could you take 15 seconds and share your happy experience on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *