ABC Bank announced a new scheme of reward points for a transaction using an ATM card. Each transaction using the normal card will be provided 1% of the transaction amount as a reward point. If a transaction is made using a premium card and it is for fuel expenses, additional 10 points will be rewarded. Write a java program to calculate the total reward points.
[Note: Strictly adhere to the object-oriented specifications given as a part of the problem statement.
Follow the naming conventions as mentioned]Consider a class
VISACardwith the following method.
Method
|
Description
|
public Double computeRewardPoints(String type, Double amount) |
This method returns the 1% of the transaction amount as reward points |
Consider a class
HPVISACardwhich extends
VISACard class and overrides the following method.
Method
|
Description
|
public Double computeRewardPoints(String type, Double amount) |
In this method, calculate the reward points from the base class and add 10 points if it is for fuel expense |
Hint:Use super keyword to calculate reward points from base class.
Consider
the Mainclass with the
main method and read all the transaction details in the main method.
Card type will be either
‘VISA card’ or ‘HPVISA card’. Otherwise, display
‘Invalid data’Calculate the reward points corresponding to the card type and transaction type and print the reward points(upto two decimal places).
The link to download the template code is given below
Code Template
Input and Output Format:Refer sample input and output for formatting specifications.
Enter the transaction details in CSV format ( Transaction type, amount, card type)
All text in bold corresponds to the input and the rest corresponds to output.Sample Input and Output 1:Enter the transaction detail
Shopping,5000,VISA cardTotal reward points earned in this transaction is 50.00
Do you want to continue?(Yes/No)
YesEnter the transaction detail
Fuel,5000,HIVISA cardInvalid data
Do you want to continue?(Yes/No)
YesEnter the transaction detail
Fuel,5000,HPVISA cardTotal reward points earned in this transaction is 60.00
Do you want to continue?(Yes/No)
NoSample Input and Output 2:Enter the transaction detail
Fuel,1000,HPVISA cardTotal reward points earned in this transaction is 20.00
Do you want to continue?(Yes/No)
No