Banking Project in core java
import java.util.*;
class Customer1
{
public static String bankName="ShashiBank";
public String name;
public double balance;
Customer1(String name)
{
this.name=name;
}
public void deposit(Double amount)
{
this.balance=this.balance+amount;
System.out.println("Avaiable amount is:"+this.balance );
}
public void withdraw(Double amount)
{
if(amount>balance)
{
System.out.println("In your Account infficiant balance");
System.exit(0);
}
else{
balance=balance-amount;
System.out.println("total Avaiable amount"+balance);
}
}
public static void main(String[]args)
{
System.out.println("\t--------Welcome to "+Customer1.bankName+"---------");
Scanner sc=new Scanner(System.in);
System.out.println("Enter Your Name");
String name=sc.next();
Customer1 c1=new Customer1(name);
System.out.println(c1.name+"Your Account is created");
while(true)
{
System.out.println("Chose Your Option ");
System.out.println("D-Deposite\nW-Withdraw\nE-Exit");
String option =sc.next();
if (option.equalsIgnoreCase("D"))
{
System.out.println("Enter Amount:");
double amount=sc.nextDouble();
c1.deposit(amount);
}
else if(option.equalsIgnoreCase("W"))
{
System.out.println("Withdraw Your amount");
double amount=sc.nextDouble();
c1.withdraw(amount);
}
else if (option.equalsIgnoreCase("E")) {
System.out.println("Thanks for using bank");
System.exit(0);
}
else{
System.out.println("Invailed option please chose the right option");
}
}
}
}
0 comments:
Post a Comment