Professional Documents
Culture Documents
Abstract - More Practice
Abstract - More Practice
Abstract - More Practice
1. Create a class CreditCard, RewardsCreditCard & TravelCreditCard based on the specification given
below
2. Have a method redeemGifts() in all three Card classes
3. Mark the method as abstract in CreditCard and inturn mark the class abstract as well
4. As mentioned above implement the logic in the other two classes.
Create a driver class named Main which creates an instance of the above-mentioned classes. Cash backs
and reward points must be calculated separately for all the base classes. If Cashbacks and reward points
are not more than 1000, display the account holder name and account number
Note: All text in bold corresponds to input and the rest corresponds to output.
//Credit Card
abstract class CreditCard {
private String accountNumber;
private Double transactionAmount;
private String holderName;
//RewardsCreditCard
class RewardsCreditCard extends CreditCard {
public void redeemGifts() {
if(super.getTransactionAmount()>=1000)
{
double n2=(super.getTransactionAmount())/100;
double n3=(Double)(n2*10);
System.out.println("You have scored "+String.format("%.1f",n3)+" reward points");
}
}
}
//Main
class Main {
public staic void main(String[] args) {
}
}