zoukankan      html  css  js  c++  java
  • 银行账户管理

    实验结果

    package 类的继承;

     import java.util.Scanner; 
     import java.math.*; 
     class Account{ 
         String name; 
         static int count=0; 
         static String[] opea=new String[100000]; 
         static double[] val=new double[1000]; 
         double balance; 
         static  String accountID="1234567891011121314"; 
         String id; 
         public Account(String name,double balance,String id){ 
             this.set(name,balance,id); 
         } 
         public void set(String name,double balance,String id){ 
             this.name=name; 
             this.balance=balance; 
             if(id.length()>18||id.length()<1){ 
                 System.out.println("Input ID Error !"); 
                 return ; 
             } 
             this.id=id; 
             accountID=add(accountID); 
         } 
         public void inquire(){ 
             System.out.println("-------账户余额信息 -------"); 
             System.out.println("balance : "+this.balance); 
             for(int i=0;i<count;i++){ 
                 System.out.println(opea[i]+" "+val[i]); 
             } 
         } 
         public String getName(){ 
             return "AccoutName : "+this.name+" AccountID "+this.accountID+" ID: "+id.substring(0,6)+"********"+id.substring(14,id.length()); 
         } 
         public double balance(){ 
             return this.balance; 
         } 
         public boolean put(double value){ 
             this.balance+=value; 
             if(value==0){ 
                 return false; 
             } 
             opea[count]="put"; 
             val[count++]=value; 
             return true; 
         } 
         public double get(double value){ 
             if(value>this.balance){ 
                 System.out.println("lack of balance !!!"); 
                 return 0; 
             } 
             opea[count]="get"; 
             val[count++]=value; 
             this.balance-=value; 
             return value; 
         } 
         public boolean exit(){ 
             return true; 
         } 
         public static String add(String str){ 
                 char[] c=new char[19]; 
                 int leng=19; 
                 int sign=0,i; 
                 for(i=0;i<19;i++){ 
                     leng=leng-1; 
                     int sum=0; 
                     sum+=str.charAt(leng)-'0'; 
                     if(i==0){ 
                         sum+=1; 
                     } 
                     sum+=sign; 
                     c[leng]=(char)(sum+48); 
                     if(sum>=10){ 
                         sign=1; 
                         c[leng]=(char)(sum%10+48); 
                     }else{ 
                         sign=0; 
                     } 
                 } 
                 return String.valueOf(c); 
         } 
     } 
     

    package 类的继承;
    class Main{ 
        public static void main(String[] args){ 
            Account p=new Account("infinite",4000,"1111111111111111"); 
            System.out.println("-------账户信息-------"); 
            System.out.printf(p.getName()); 
            System.out.println(); 
            System.out.println("balance : "+p.balance()); 
            p.put(153213); 
            p.inquire(); 
            System.out.println(); 
             
           
        } 

  • 相关阅读:
    excel数据导入mySql数据库
    springboot-devtools实现项目的自动重启
    Java中List, Integer[], int[]的相互转换
    Postman代码测试工具如何用?
    git提交代码时,Unstaged changes如何过滤.class .log等文件
    Json字符串转map集合
    实现hibernate 的validator校验
    [转载]OpenSSL中文手册之命令行详解(未完待续)
    Openssl ASN.1 说明一 分享
    [转载]Parsing X.509 Certificates with OpenSSL and C
  • 原文地址:https://www.cnblogs.com/infinite14/p/8965143.html
Copyright © 2011-2022 走看看