标签:
3.编写Java应用程序。首先定义一个描述银行账户的Account类,包括成员变
量“账号”和“存款余额”,成员方法有“存款”、“取款”和“余额查询”。其次,
编写一个主类,在主类中测试Account类的功能。
package liu0918; public class Account { long zhanghao; double yue; double cunkuan; double qukuan; Account(long z,double y,double c,double q) { zhanghao=z; yue=y; cunkuan=c; qukuan=q; }
long getZhanghao()
{
return zhanghao
}
double getCunkuan() { return cunkuan; } double getQukuan() { return qukuan; } double getYue() { yue=yue+cunkuan; yue=yue-qukuan; return yue; } }
package liu0918; public class Xianshiyue { public static void main(String[] args) { Account a=new Account(37030219921103****L,1000.0,500.0,200.0); System.out.println("账号:"+a.getZhanghao()+"原始余额是="+a.yue); System.out.println("账号:"+a.getZhanghao()+"存款是="+a.getCunkuan()); System.out.println("账号:"+a.getZhanghao()+"取款是="+a.getQukuan()); System.out.println("账号:"+a.getZhanghao()+"余额是="+a.getYue()); } }
标签:
原文地址:http://www.cnblogs.com/liuyanzeng/p/5882721.html