标签:
package com.hanqi.test;
import java.util.Scanner;
public class account {
long zhanghao;
double yu_e;
double cunkuan;
double qukuan;
account(long zh,double yu)
{
zhanghao=zh;
yu_e=yu;
}
void getCunkuan()
{
Scanner sc=new Scanner(System.in);
System.out.println("请输入您的存款金额:");
double ck=sc.nextDouble();
System.out.println("您的存款金额为:"+ck+"余额为:"+(yu_e+ck)+"元");
}
void getQukuan()
{
Scanner scq=new Scanner(System.in);
System.out.println("请输入您的取款金额:");
double qk=scq.nextDouble();
System.out.println("您的款金额为:"+qk+"余额为:"+(yu_e-qk)+"元");
}
double getYu_echaxun()
{
return yu_e;
}
}
package com.hanqi.test;
import java.util.Scanner;
public class Test05 {
public static void main(String[] args) {
account ac=new account(6221500,10000);
System.out.println("您的账号名为:"+ac.zhanghao);
System.out.println("请选择您的服务:");
System.out.println("1:取款");
System.out.println("2:存款");
System.out.println("3:余额查询");
Scanner sc=new Scanner(System.in);
int select=sc.nextInt();
if(select==1)
{
ac.getQukuan();
}
if(select==2)
{
ac.getCunkuan();
}
if(select==3)
{
System.out.println("当前余额为:"+ac.getYu_echaxun()+"元");
}
}
}
标签:
原文地址:http://www.cnblogs.com/diaozhaojian/p/5883591.html