class DoWhileDemo {
public static void main(String[] args){
int count = 1;
do {
System.out.println("Count is: "
+ count);
count++;
} while (count <= 11);
}
}
can someone please rxplain to me how does Do while statements work?
and how can i use it in my program?:
public static void main(String[] args) {
String a =(JOptionPane.showInputDialog(null, "Automatic Teller Machine\n [B] Balance Inquiry\n [D]Deposit\n [W] Withdrawal\n [Q] Quit\n Select you Options: ","Automatic Teller Machine",JOptionPane.PLAIN_MESSAGE));
String B= "B";
String D="D";
String W="W";
int balance= 0;
int deposit = 0;
int withdraw= 0;
int bal = 0;
int wht = 0;
int ans;
int trans = 0;
if(a.equalsIgnoreCase(B))
{
JOptionPane.showMessageDialog(null, "Your Balance is: ","BALANCE INQUIRY",JOptionPane.PLAIN_MESSAGE );
ans=JOptionPane.showConfirmDialog(null, "Would you like to generate bank slip?","Generate Bank Slip",JOptionPane.YES_NO_OPTION);
if (ans == 1){ //no
JOptionPane.showConfirmDialog(null,"Would You Like Another Transaction?","Another Transaction",JOptionPane.YES_NO_OPTION);
if (trans == 1)
{
JOptionPane.showMessageDialog(null, "Thanks For Using My Program!!");
}
else if (trans == 0)
{
String b =(JOptionPane.showInputDialog(null, "Automatic Teller Machine\n [B] Balance Inquiry\n [D]Deposit\n [W] Withdrawal\n [Q] Quit\n Select you Options: ","Automatic Teller Machine",JOptionPane.PLAIN_MESSAGE));
}
}
else if (ans == 0){ // yes
JOptionPane.showMessageDialog(null, "BALANCE INQUIRY \n AMOUNT BALANCE: "+ balance+ "\nPrinting Bank slip.....");
}
}
else if (a.equalsIgnoreCase(D))
{
int dep =Integer.parseInt(JOptionPane.showInputDialog (null,"Enter Your Deposit Amount" ));
balance = dep - wht;
ans=JOptionPane.showConfirmDialog(null, "Would you like to generate bank slip?","Generate Bank Slip",JOptionPane.YES_NO_OPTION);
if (ans == 1){ //no
JOptionPane.showConfirmDialog(null,"Would You Like Another Transaction?","Another Transaction",JOptionPane.YES_NO_OPTION);
if (trans == 1)
{
JOptionPane.showMessageDialog(null, "Thanks For Using My Program!!");
}
else if (trans == 0)
{
String c =(JOptionPane.showInputDialog(null, "Automatic Teller Machine\n [B] Balance Inquiry\n [D]Deposit\n [W] Withdrawal\n [Q] Quit\n Select you Options: ","Automatic Teller Machine",JOptionPane.PLAIN_MESSAGE));
}
}
else if (ans == 0){ // yes
JOptionPane.showMessageDialog(null, "DEPOSIT INQUIRY \n AMOUNT DEPOSIT: "+ dep+ "\nPrinting Bank slip.....");
}
}
else if (a.equalsIgnoreCase(W))
wht= Integer.parseInt(JOptionPane.showInputDialog(null," Enter the Withdrawal Amount:"));
if (balance < wht){
JOptionPane.showMessageDialog(null, "Insufficient Amount");
}
else if (balance >= wht){
}
}
}
thank u, please dont get tired answering my questions!