zoukankan      html  css  js  c++  java
  • 银行存取款练习

    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);

    }

    }

  • 相关阅读:
    树链剖分学习笔记(未完)
    VI 配置文件(略全)
    linux之awk
    指针之基础篇
    linux之sed
    sqlplus命令手册
    Leetcode复习: 堆和栈
    leetcode 的shell部分4道题整理
    Regular Expression Matching [leetcode]
    深入浅出JAVA
  • 原文地址:https://www.cnblogs.com/-strong/p/7050265.html
Copyright © 2011-2022 走看看