Question: Please write the output of the following program: public class Transactions { public static void main(String[] args) { Account acct1 = new Account( Alice Smith

Please write the output of the following program:

public class Transactions

{

public static void main(String[] args)

{

Account acct1 = new Account("Alice Smith", 101, 100.00);

System.out.println("Alice balance after withdrawal: " + acct1.withdraw (10, 2.50));

double AdaBalance = acct1.deposit(100.00);

System.out.println("ALice balance after deposit: " + AdaBalance);

acct1.addInterest();

System.out.println(acct1);

}

}

import java.text.NumberFormat;

public class Account

{

private final double RATE = 0.01;

private long acctNumber;

private double balance;

private String name;

public Account(String owner, long account, double initial)

{

name = owner;

acctNumber = account;

balance = initial;

}

public double deposit(double amount)

{

balance = balance + amount;

return balance;

}

public double withdraw(double amount, double fee)

{

balance = balance - amount - fee;

return balance;

}

public String addInterest()

{

NumberFormat fmt = NumberFormat.getCurrencyInstance();

balance += (balance * RATE);

return (acctNumber + "\t" + name + "\t" + fmt.format(balance));

}

public String getBalance()

{

NumberFormat fmt = NumberFormat.getCurrencyInstance();

return (acctNumber + "\t" + name + "\t" + fmt.format(balance));

}

public String toString()

{

NumberFormat fmt = NumberFormat.getCurrencyInstance();

return (acctNumber + "\t" + name + "\t" + fmt.format(balance));

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!