标签:
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(); 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()+"元"); } } }
标签:
原文地址:http://www.cnblogs.com/HRZJ/p/5883213.html