银行存取款练习

package *********;

import java.util.Scanner;
public class YH {
private String name;
// 定义卡(a)的属性
private String id;
// 定义卡(a)的属性
private double money;
// 定义卡(a)的属性

// 构造函数
YH(String a, String b, double c) {
this.name = a;
this.id = b;
this.money = c;
}
public static void main(String[] args) {

// TODO Auto-generated method stub

YH a = new YH("**", "123456789", 1000);

// new出一个对象a,实参发送到构造函数的形参

System.out.println("账户名=" + a.name + " " + "账号=" + a.id);
//接收构造函数的基本信息,输出a对象的账户名以及账号。
System.out.println("账户存款= " + a.money);

System.out.println("请输入存款额度:");
//输出提示信息
Scanner sc = new Scanner(System.in);
double x1 = sc.nextDouble();
//定义一个变量X1接受键盘输入信息
System.out.println("存款额度=" + x1);
a.cunkuan(x1);
//调用普通函数cunkuan,
}

void cunkuan(double x1) {

//存取款普通函数
double sum = x1 + money;
//本次(存取款)计算方法


System.out.println("剩余额度=" + sum);

}

}

posted @ 2017-06-19 19:42  冰逸101  阅读(218)  评论(0编辑  收藏  举报