package com.sudhirtheindian2.java123;
import java.util.Scanner;
public class MyBank {
private double balance =2000;
private int password;
public void deposit(double money){
System.out.println("Enter the password");
Scanner sc = new Scanner(System.in);
password= sc.nextInt();
if(password ==1999){
balance = balance+money;
System.out.println("Deposited money"+money);
System.out.println("tatal money is:"+balance);
}
else {
System.out.println("wrong password try again....");
}
}
public void withdraw(double money){
System.out.println("Enter the password");
Scanner sc = new Scanner(System.in);
password = sc.nextInt();
if(password==1999){
balance = balance-money;
System.out.println("withdrawn money"+money);
System.out.println("total balane "+balance);
}
else {
System.out.println("wrong password please try again ...");
}
}
public void chekbalance(){
System.out.println("enter the password");
Scanner sc = new Scanner(System.in);
password =sc.nextInt();
if(password ==1999){
System.out.println("total balance is"+balance);
}
else {
System.out.println("wrong password");
}
}
public static void main(String[] args) {
MyBank b = new MyBank();
int choice ;
System.out.println("1.. deposite the money");
System.out.println("2.. withdraw the money ");
System.out.println("3.. check the balance");
System.out.println("enter your choice ");
Scanner sc = new Scanner(System.in);
choice= sc.nextInt();
switch (choice){
case 1:
b.deposit(5000);
break;
case 2:
b.withdraw(2000);
break;
case 3:
b.chekbalance();
break;
default:
System.out.println("wrong choice");
}
}
}
рдЯिрдк्рдкрдгिрдпाँ
рдПрдХ рдЯिрдк्рдкрдгी рднेрдЬें