EXP (5)-1
EXP (5)-1
QUESTION :
CODE:
interface CreditCardInterface {
void viewCreditAmount();
void viewPin();
String name;
String cardNumber;
int pin;
double creditAmount;
this.name = name;
this.cardNumber = cardNumber;
this.pin = pin;
System.out.println("Current Credit Amount for " + name + " (" + cardNumber + "): $" +
creditAmount);
System.out.println("Current PIN for " + name + " (" + cardNumber + "): " + pin);
this.pin = newPin;
System.out.println("PIN changed successfully for " + name + " (" + cardNumber + ")");
} else {
creditAmount -= amount;
System.out.println(name + " paid $" + amount + " towards the balance. Remaining
Credit: $" + creditAmount);
}
public void addCredit(double amount) {
creditAmount += amount;
customers[0].viewCreditAmount();
customers[0].viewPin();
customers[1].viewCreditAmount();
customers[1].viewPin();
}
}
OUTPUT:
John Doe paid $200.0 towards the balance. Remaining Credit: $800.0
Alice Smith paid $100.0 towards the balance. Remaining Credit: $400.0