服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

银行取款机cash系统源程序


  这是一个关于银行取款机的程序,觉得知识有限,请高手们帮我改改,让我的程序更加的完善!!谢谢各位!!!!!
  
  
   // cash.java
   // a miniproject in bank system
  
   //import extension packages
   import javax.swing.*;
  
   public class cash
   {
   public static void main( string args[] )
   {
   /* initializer list specifies number of element and
   value for each element */
   int password[] = { 1111,2222,3333,4444,5555,6666 };
   int supe; // int first value
   int cash = 8888; // number of money
   int money = 0; // int third value
   int i = 1; // number of i
  
   // a do/while loop
   do
   {
   // string a value and read in password from user
   string supesum =
   joptionpane.showinputdialog( "welcome to use this cash systerm!/n"+
   "now please enter your password :" );
  
   // convert numbers from type string to type int
   supe = integer.parseint( supesum );
  
   // a if/else control structer
   if ( supe==password[0]
   || supe==password[1]
   || supe==password[2]
   || supe==password[3]
   || supe==password[4]
   || supe==password[5] )
  
   break;
  
   else
   joptionpane.showmessagedialog(null,"you put in the password is wrong!/n"+
   "please try again" );
  
   }
   while( i>0 );
  
   //show the option table for user to choose
   //set a loop to see whether the choise is 1, 2 or 3
  
   int choise; // int a vlaue
  
   while( i==1 )
   {
  
   do
   {
   // string a value and read in choise from user
   string inputchoise =
   joptionpane.showinputdialog ( "/tenter your choise :/n" +
   "/t/t 1 check your cash-card'cash/n" +
   "/t/t 2 pick out your cash/n" +
   "/t/t 3 put in your cash/n" +
   "/t/t 4 exit" );
  
   // convert number from type string to type int
   choise = integer.parseint( inputchoise );
  
   switch( choise )
   {
   case 1 :
   joptionpane.showmessagedialog( null,"your cash-card have got " + cash );
   break;
  
   case 2 :
   // string a value and read in money from user
   string out =
   joptionpane.showinputdialog( "how much do you want to pick out ?/n"+
   "please input the cash number in the blank dialog!" );
   money = integer.parseint( out );
   cash = cash - money;
   break;
  
   case 3 :
   // string a value and read in money from user
   string in =
   joptionpane.showinputdialog( "how much do you want to put in ?/n"+
   "please input the cash number in the blank dialog!" );
   money = integer.parseint( in );
   cash = cash + money;
   break;
  
   case 4 :
   joptionpane.showmessagedialog( null, "thank you for use this cash systerm!" );
  
   system.exit(0);
   }
  
   }
   while( choise<1 || choise>4 );
  
   } //end the loop
  
   system.exit(0);
  
   } // end method close
  
   } // end class bank

扫描关注微信公众号