System.out.println("Do you want to deposite or withdraw? (D/W)");
String answer;
answer = input.nextLine();
if("D" === answer)// Thing need to help
{
System.out.println("Enter deposite ammount: ");
depositeAmmount = input.nextDouble();
System.out.printf("adding %.2f to account1\n\n", depositeAmmount);
acc1.Credit(depositeAmmount);
System.out.format("ballance of account1 is: %.2f\n", acc1.getBallance());
System.out.format("ballance of account2 is: %.2f\n\n", acc2.getBallance());
}
else if(){
System.out.println("Enter withdraw ammount: ");
withdrawAmmount = input.nextDouble();
System.out.printf("differing %.2f to account1\n\n", depositeAmmount);
acc1.Withdraw(withdrawAmmount);
System.out.format("ballance of account1 is: %.2f\n", acc1.getBallance());
System.out.format("ballance of account2 is: %.2f\n", acc2.getBallance());
}
else{
System.out.println("The answer you input is invalid! Please input again!\n");
answer = input.nextLine();
}
As you can see I want to create the withdraw and deposit action using if, how can I assign the answer to character D or W to do this code. Can you guy show me how to do? Thanks a lot!