Thursday 15 September 2011

java - The else if section is not working -


And if the deposit amount is not working and if there is no number for the balance update then That's the case. / P> Public-class bank account (fixed double balance); Public static zero main (string [] args) {scanner sc = new scanner (System.in); System.out.println ("Enter the name of the account holder ..."); String name = sc.next (); System.out.println ("Enter his account number ..."); Long time AccNo = sc.nextLong (); System.out.println ("Enter the type of your account ..."); String accTyp = sc.next (); System.out.println ("Enter its current balance ..."); Balance = sc.nextDouble (); System.out.println ("Do you want to update your balance, for y, press y and not for n ..."); If (sc.next (). Equals sign ("y") == true) {System.out.println ("Press to extract money, submit it to, press D"); If (sc.next (.) Equal ignoreCase ("w") == true) {System.out.println ("Account holder withdrawn amount"); Double take back = sc.next double (); Double Balo = Recoil (back); System.out.println ("account holder" + name + "with account number" + AccNo + "and account type" + AccTyp + "has new balance =" + hair); } Else if (sc.next). Equal unknown ("D") == true) {System.out.println ("Account holder deposit amount entered"); Double deposit = sc.nextDouble (); Double hair = deposited (deposited); System.out.println ("account holder" + name + "with account number" + AccNo + "and account type" + AccTyp + "has new balance =" + hair); } Else System.out.println ("Thank you for your transaction"); } And if (sc.next (.) Ignore equals ("n") == true) {System.out.println ("Thank you for your transaction"); } System.out.println ("Thank you for your transaction"); } Public Static Double Return (Double A) {Balance = Balance - A; Return balance; } Public Fixed Double Deposit (Double B) {Balance = Balance + B; Return balance; }}

Do not apply () Method:

  if (sc.next (). Equally narrow case ("w") == true) ... and if (sc.next () .all ignoreCase ("d") = = True)   

The code should be something like this instead:

  string response = sc.next (); If (response.equalsIgnoreCase ("w") ... and if (response.equalsIgnoreCase ("d")) ...    

No comments:

Post a Comment