package com.zhongguo.javase.D14;
public class Dam16 {
int kahao; int yue; public Dam16(){ } public Dam16(int a,int b){ this.kahao=a; this.yue=b; } void add(int c){ this.yue=yue+c; System.out.println("存款:"+c); this.yue=yue; } void cut(int c){ this.yue=yue-c; System.out.println("取款:"+c); this.yue=yue; } public static void main(String []args){
Dam16 h=new Dam16(1111,80000); h.add(80000); h.cut(170000); if(h.yue<0){ System.out.println("余额不足"); } else{ System.out.println("余额为:"+h.yue+"元"); } System.out.println("卡号为:"+h.kahao);}
}
情形之一:余额不足
存款:80000
取款:170000余额不足卡号为:1111