JavaScript Project – ATM Bank Application Part – 1

Full Stack Web Development Courses with Real-time projects Start Now!!

Program 1

// ATM Application for Bank
"use strict"
const ps=require("prompt-sync")
const prompt=ps({sigint:true})

class Bank
{
    constructor(acno,name,amount=0)
     {
       // console.log("This is create account method") 
        this.acno=acno
        this.name=name
        this.amount=amount
    }
    deposit(amount=0)
    {
        this.amount=this.amount+amount
    }
     withd(amount)
    {
        this.amount=this.amount-amount
    }
    displaybalance()
    {
       console.log("Account id: "+this.acno)
       console.log("Account Hoder Name: "+this.name)
       console.log("Balance: "+this.amount)
    }
}

let choice
let B1=new Bank(101,'Vikas Sharma',6000)
// let B2=new Bank(102,'Rajesh Gupta',2000)
// let B3=new Bank(103,'Sheetal Verma',3000)
// let B4=new Bank(104,'Sahil',5000)
// let B5=new Bank(105,'Ashish',7000)

do
{
    console.log("--------------------Bank ATM-------------------------")
    console.log("                    1.Deposit")
    console.log("                    2.Withdrawal")
    console.log("                    3.Balance Check")
    console.log("                    4.Exit")
    console.log("---------------------------------------------------------")
    choice=parseInt(prompt("Enter your choice"))

    switch(choice)
    {
       case 1: 
       {
          let amt=parseInt(prompt("Enter amount for deposit: "))
          B1.deposit(amt); break;
       }
       case 2: 
       {
           let amt=parseInt(prompt("Enter amount for withdrawal: ")) 
           if(amt>B1.amount)
              console.log("Insufficient balance: ")
            else
             B1.withd(amt);break;
       }
       case 3: B1.displaybalance();break;
       case 4:break;
    }
}while(choice!=4);

 

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

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

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