Bank accounts

package bank account;
import java.util.Date;   
import java.text.SimpleDateFormat;   
   

public class BANK {
    private String name,zhanghao,id;
    private double yue;
    public BANK(String n,String id,String zhanghao)   
    {   
        this.id =id;
        this.zhanghao=zhanghao;
        name = n;   
        yue = 0;   
    }
    public String getinformation()
    {
        return "Name of depositor"+name+"\nID number of depositor: "+id+"\nBank account number: "+ zhanghao ;
    }
    
    public double getyue()
    {
        return yue;
    }
    
    public double CK(double money)
    {
        yue=yue+money;
        return money;            
    }
    public double QK(double money)
    {
        if(money>yue)
        {
            System.out.println("Insufficient balance, unable to withdraw money! The balance is "+yue);
            return 0;        
        }
        else
        {
            yue=yue-money ; //The withdrawal operation reduces the balance value   
            return money;  
        }
    }
    public String Date1()   
    {   
        Date today=new Date();   
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy year MM month dd day hh hour mm minute ss second a EEEEE" );   
        return sdf.format(today);  
    }
}

package bank account;

import java.util.Scanner;

public class MAIN
{
    public void main(String args[])
    {
        BANK S1=new BANK("XIAXIA", "40002", "100003");
        double m;
        System.out .println("-----------account information---------");
        System.out.println("Your account name is "+S1.getinformation());   
        System.out.println("Your account balance is "+S1.getyue()+"Yuan");
        System.out.println("-----------operate----- ----");
        System.out.println("Your current deposit"+S1.CK(1000)+"Yuan");
        System.out.println("Your account balance is"+S1.getyue( )+"yuan");  
        Scanner s=new Scanner(System.in);
        System.out.println("Please enter the withdrawal amount: ");
        m=s.nextInt();
        System.out.println("Your current withdrawal"+S1.QK(m)+"Yuan"); //The withdrawal amount greater than the balance
        System.out.println("Your account balance is "+S1.getyue( )+"Yuan");
        System.out.println("The time is"+S1.Date1());
        System.out.println("Your withdrawal this time"+S1.QK(m)+"Yuan"); //The withdrawal amount less than the balance
        System.out.println("Your account balance is "+S1.getyue()+"Yuan");
        System.out.println("The time is "+S1.Date1());
    }

}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325135347&siteId=291194637