⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 practice6_1.java

📁 模拟银行程序
💻 JAVA
字号:
import javax.swing.JOptionPane;
class Practice6_1{
	public static void main(String[] args)
	{
		double newBalance=0;
		double balance=0;
		double adjustment=0;
		String response;
		String moreBankingBusiness;
		moreBankingBusiness = JOptionPane.showInputDialog
		("do you want to do some banking?");
		moreBankingBusiness=moreBankingBusiness.toUpperCase();
		  while(moreBankingBusiness.equals("YES")){
			  response=JOptionPane.showInputDialog
			    ("What would you want to do ?(1=Deposit,2=Withdraw,3=GetBalance)");
			    if(response==null)
			    {
					JOptionPane.showMessageDialog
					      (null,"You clicled on the Cancel button.");
					     System.exit(0);
				 }
				  else
				  if(response.equals(""))
				  {
					  JOptionPane.showMessageDialog
					     (null,"You nust make an entry in the InputBox.");
					     System.exit(0);
					 }
					 else
					 if(Integer.parseInt(response)<1|Integer.parseInt(response)>3)
                    {
						JOptionPane.showMessageDialog
						   (null,response+"is not vaild banking function");
						  System.exit(0);
					  }
					  //1 is a Deposit
					  if(Integer.parseInt(response)==1)
					  {
						  adjustment=Double.parseDouble
						     (JOptionPane.showInputDialog("Enter the Deposit Amount"));
						   newBalance=balance+adjustment;
						   JOptionPane.showMessageDialog
						      (null,"***SMILEY NATIONAL BANK***\n\n"+
						              "Old Balance is:"+balance+"\n"+
						              "Adjustment is :"+adjustment+"\n"+
						              "New Balance is:"+newBalance+"\n");

				          }
				        //2 is a Withdrawal
				       if(Integer.parseInt(response)==2)
				       {
						    adjustment=Double.parseDouble
						   (JOptionPane.showInputDialog("Enter the Withdrawal Amount"));
						   	newBalance=balance-adjustment;
						   	JOptionPane.showMessageDialog
						      (null,"***SMILEY NATIONAL BANK***\n\n"+
						            "Old Balance is:"+balance+"\n"+
						            "Adjustment is :"+adjustment+"\n"+
						            "New Balance is:"+newBalance+"\n");
						  }
						//3 is a Balance Inquiry
					   if(Integer.parseInt(response)==3)
						 {
						      JOptionPane.showMessageDialog
						      (null,"***SMILEY NATIONAL BANK***\n\n"+
						             "Your Current Banace is:"+balance);
						  }
						balance=newBalance;
						moreBankingBusiness=JOptionPane.showInputDialog
						    ("Do you have more banking business?");
						moreBankingBusiness=moreBankingBusiness.toUpperCase();
					  }//end of while
					  JOptionPane.showMessageDialog(null,"Thanks for banking with us!!!");
					    System.exit(0);
					}
				}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -