zoukankan      html  css  js  c++  java
  • 编写Java应用程序。首先定义一个描述银行账户的Account类,包括成员变 量“账号”和“存款余额”,成员方法有“存款”、“取款”和“余额查询”。其次, 编写一个主类,在主类中测试Account类的功能。

    package com.homework.zw;
    
    import java.util.Scanner;
    
    public class YinHang
    {
        long zhanghao;
        double yue;
        double ck;
        double qk;
        
        YinHang(long zh,double ye)
        {
            zhanghao=zh;
            yue=ye;
        }
        
        void getcunkuan()
        {
            Scanner sc1=new Scanner(System.in);
            System.out.println("请输入存款数目:");
            double cun=sc1.nextDouble();
            System.out.println("您的存款数目为:"+cun+"元"+"  账户余额为:"+(yue+cun)+"元");
        }
        void getqukuan()
        {
            Scanner sc1=new Scanner(System.in);
            System.out.println("请输入取款数目:");
            double qu=sc1.nextDouble();
    if(qu>yue)
       {
        System.out.println("您的余额不足");
       }
       else System.out.println(
    "您的取款数目为:"+qu+"元"+" 账户余额为:"+(yue-qu)+"元"); } double getchaxunyue() { return yue; } }
    package com.homework.zw;
    
    import java.util.Scanner;
    
    public class Textyinhang
    {
        public static void main(String[] args)
        {
            YinHang yh= new YinHang(6227002210912572566l,8563.4);
            System.out.println("当前账户为:"+yh.zhanghao);
            System.out.println("请选择服务类型:");
            System.out.println("1.存款");
            System.out.println("2.取款");
            System.out.println("3.余额查询");
            Scanner sc=new Scanner(System.in);
            int xuanze = sc.nextInt();
            if(xuanze==1)
            {
                yh.getcunkuan();
            }
            if(xuanze==2)
            {
                yh.getqukuan();
            }
            if(xuanze==3)
            {
                System.out.println("当前余额为:"+yh.getchaxunyue()+"元");
            }
        }
    
    }

  • 相关阅读:
    Golang 开发环境安装和配置
    多测师肖老师__接口测试之cms搭建(27.1)
    多测师肖老师__接口测试之fn+f12查看接口(27.2)
    认识wpf中binding类型
    认识wpf的事件
    Jquery对象与Dom对象
    AS3编程中的两种常用事件
    SQL Server 系统表简介
    Winform中ComcoBox控件设置选定项
    wpf开篇入门
  • 原文地址:https://www.cnblogs.com/HRZJ/p/5883213.html
Copyright © 2011-2022 走看看