You need to create a class that maintains a customer’s account balance. The class must allow
both credits (deposits) and debits (withdrawals) to the account.
Which class correctly implements this functionality?
A.
public class Account {
double balance;
public void debit(double amount) {
amount = balance – amount;
}
public void credit(double amount) {
amount = balance + amount;
}
B.
public class Account {
double balance;
public void debit(double amount) {
balance = balance – amount;
}
public void credit(double amount) {
balance = balance + amount;
}
C.
public class Account {
double balance;
balance = balance – amount;
}
public void credit(double amount) {
double balance;
balance = balance + amount;
}
D.
public class Account {
public void debit(double amount) {
double balance;
balance = balance – amount;
}
public void credit(double amount) {
double balance;
balance = balance + amount;
}
E.
public class Account {
double balance;
public void debit() {
double debit;
balance = balance – debit;
}
public void credit() {
double credit
balance = balance + credit;
}