Java定义一个表示人民币的类Money,

2022-08-04 财经 220阅读
public class Money {
private int yuan;
private int jiao;
private int fen;

public Money(int yuan,int jiao, int fen){
this.yuan=yuan;
this.jiao=jiao;
this.fen=fen;

}

public void show(){

System.out.printf("%d元%d角%d分",yuan,jiao,fen);

}

public static void main(String[] args) {
Money m=new Money(4,5,6);
m.show();

}

}
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com