?? practice6_1.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 + -