标签:pack system.in bank inf int() main get 银行 操作
package 银行账户;
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+"\n储户身份证号:"+id+"\n银行账号:"+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("余额不足,无法取款!余额为"+yue);
return 0;
}
else
{
yue=yue-money; //取款操作使余额值减少
return money;
}
}
public String Date1()
{
Date today=new Date();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy 年 MM 月 dd 日 hh 时 mm 分 ss 秒 a EEEEE");
return sdf.format(today);
}
}
package 银行账户;
import java.util.Scanner;
public class MAIN
{
public void main(String args[])
{
BANK S1=new BANK("XIAXIA", "40002", "100003");
double m;
System.out.println("-----------帐户信息---------");
System.out.println("您的储户名为"+S1.getinformation());
System.out.println("您的帐户余额为"+S1.getyue()+"元");
System.out.println("-----------进行操作---------");
System.out.println("您本次存款"+S1.CK(1000)+"元");
System.out.println("您的账户余额为"+S1.getyue()+"元");
Scanner s=new Scanner(System.in);
System.out.println("请输入取款额:");
m=s.nextInt();
System.out.println("您本次取款"+S1.QK(m)+"元"); //大于余额的取款额
System.out.println("您的账户余额为"+S1.getyue()+"元");
System.out.println("时间为"+S1.Date1());
System.out.println("您本次取款"+S1.QK(m)+"元"); //小于余额的取款额
System.out.println("您的账户余额为"+S1.getyue()+"元");
System.out.println("时间为"+S1.Date1());
}
}
标签:pack system.in bank inf int() main get 银行 操作
原文地址:https://www.cnblogs.com/xxym/p/8977330.html