import java.util.Scaer ;
public class CustomerAccount
{
public static void main( String[] args )
{
Scaer in = new Scaer(System.in);
System.out.print("Please enter the account number: ") ;
String accountNumber = in.nextLine() ;
int newBalance = updateBalance() ;
System.out.print("Account Number: " + accountNumber ) ;
System.out.print(" Updated Balance: $" + newBalance) ;
}
public static int updateBalance()
{
Scaer in = new Scaer(System.in) ;
System.out.print("Please enter the initial balance: ") ;
int initBalance = in.nextInt() ;
System.out.print("Please enter the transaction type/(D to deposit, W to withdraw, Q to quit: ") ;
String transactionType = in.nextLine();
System.out.print("Please enter the amount to be deposited or withdrawn: ") ;
int adjustment = in.nextInt();
if (transactionType == "D")
{
int newBalance = initBalance + adjustment ;
retu newBalance;
}
else if(transactionType == "W")
{
int newBalance = initBalance - adjustment ;
retu newBalance;
}
else if(transactionType == "Q")
{
retu initBalance;
}
retu initBalance ;
}
}
I am trying to code a program which uses different methods. First the main method needs to print the account number and updated balance after every transcation(until a Q is entered to quit entering transcations).
Next updateBalance, given the balance of the account, the type of transaction, and the amount for the transaction, it comptuers and retus the new account balance after depositing or withdrawing the amount
Looking back at my code I think I might need to implement a while loop with the condition being not equal to Q and then have my if statements inside of that while loop.
