HELLO DORAEMONS,
IRA SBQ PYTHON 9th dec Xperience
IRA Python - Credit Card Rewards
Reward points are considered to be one of the most attractive benefits offered by credit cards. Whenever, one uses a credit card, a few reward points are credited in his/her account.
Write a program to define classes to create a credit card object and a Customer object as per the following requirement.
A Credit Card has following attributes:
• card number (an alpha numeric value)
• name of the card holder (a string of characters)
• name of the Bank (a string of characters)
• date of expiry (a string in the format dd-mm-yyyy)
• card balance (a number value representing the existing credit amount on the card)
• a credit limit (a number value)
• reward benefit schemes - defines the applicable reward points earned per Rs 100 spent against a list of items/services. Maintained in the form of key value pairs as "tuple of items: points earned".
For example:
If for a card, 3 Reward Points are added for every Rs.100 spent on
groceries and supermarkets along with 2 Reward Points for every
Rs. 100 spent on dining and telecom, it should be stored as follows:
{{ "groceries", "supermarkets"):3,
"dining", "telecom"):2}
Define a method in the class to initialize the attributes with given set of values when an object of the type is created . A Customer has a list of Credit Cards as attribute Define a method in the class to initialize the attributes with given set of values when an object of the type is created.
A Customer can use his/her credit cards to make payment for purchases (online/offline). Based on the amount to be paid on, customer chooses the card from
his/her credit card list, which has:
• Not expired yet
• has the maximum remaining credit balance.
• Payment amount is not beyond the remaining credit limit.
For example if a customer has following 4 credit cards:
1.card number : AX12345
name of the card holder : Ranjan Gogoi
name of the Bank :HDFC
date of expiry :01-05-2021
card balance : 200
credit limit:5000
Reward benefit Scheme: {(
“groceries", "supermarkets"):3, fodining"
,"telecom"):2)
2.card number : AB22345
name of the card holder : Ranjan Gogoi
name of the Bank :ICICI
date of expiry :01-05-2022
card balance: 8000
credit limit:10000
Reward benefit Scheme: {(
"groceries", "supermarkets"):3,( "dining
"telecom"):2)
3.card number: CBX3323490
name of the card holder: Ranjan Gogoi
name of the Bank SBI
date of expiry :01-05-2022
card balance : 20000
credit limit:50000
Reward benefit Scheme: (
"groceries", "supermarkets"):3,( "dining"
"telecom"):2)
4.card number : AXX22345
name of the card holder : Ranjan Gogoi
name of the Bank :AXIS
date of expiry :01-05-2022
card balance : 10000
credit limit:50000
Reward benefit Scheme: {(
":6-
"groceries", "supermarkets"): 3, (dining"
,"telecom"):2)
and the amount to be paid on 15-09-2021 is 3000, Customer will select the 4th card.
If customer is able to make the payment using a card, the card balance(Existing credit amount) is increased by the amount
spent. Also the reward points are credited to the cardholder's account based on the available reward benefit schemes of the card for the Item/Service for which the payment is made. If the item/services for which the card is to be used for payment is not in any of the reward benefit scheme's of the card, the default reward point will be considered as 1 per 100 Rupees spent.
Note:• To earn a credit point, a minimum of Rs 100 needs to be spent.
• All the string comparisons should be case insensitive.
Define a method in the class to calculate the reward points to be credited to the Customer's account for buying an item or making a payment using a credit card.
Method should fulfill the requirements defined above.
In case Customer does not have a valid Credit Card to make the payment, the reward points to be credited to the Customer's account will be considered as 0.
After defining the classes as described above, write the main section completely, in line to the "Sample input description section" mentioned below and to read the data in the same sequence
Sample input description:
Write code to read attribute values to create a list of objects of type Credit Card.
a. Read a number for the count of Credit Card objects to be created and added to the list.
b. Create a Credit Card object after reading the data related to it and add the object to the list of objects. For each Credit Card object read the values for:
• card number
• name of the card holder
• name of the Bank
• date of expiry
• card balance
• a credit limit
• reward benefit schemes - for this,
1. read a number (x) representing count of reward benefit schemes applicable
2. read a number (n) to be considered as count of items/services for which the reward point (n) earned is same per Rs 100 spent.
3. read n number of strings (items /services) and create the tuple.
e. Using the Customer object created, calculate the reward points to be credited to the Customer's account for the payment details taken as input in point #c above.
f. Display a message "Reward points to be credited to the Customer's account =" (excluding the quotes). Print the reward point value calculated in the same line.
For example:
Reward points to be credited to the Customer's account =200
In the next line, display a message "Card details after payment:" (excluding the quotes)
g. Display the card number the remaining credit balance of the card and the card balance for all the Credit Cards created above one by one in separate
Values for the card number, the remaining credit balance and card balance should be separated by
For example:
Card details after payment:
Ax12345, 9000, 5000
BCX223345, 1200D, 5000
Note: In the output the card details should appear in the same sequence as per input. You can use for the below given sample input and output to verify your solution using Test against Custom Input option in Hackarrank
Sample Testcase 1:
Input :
4
AX12345
Ranjan Gogoi
HDFC
1-05-2021
200
5000
3
2
dining
telecom
2
2
Groceries
Supermarkets
3
3
Hotel
Fuel
Medicine
AB22345
Ranjan Gogol
ICICI
1-05-2022
10000
11000
2
3
dining
telecom
Hotel
5
2
Groceries
Supermarkets
3
CBX3323
Ranjan Gogoi
SBI
1-05-2022
20000
50000
3
2
dining
telecom
4
2
Groceries
Supermarkets
3
3
Hotel
Fuel
Medicine
5
AXX2234
Ranjan Gogoi
AXIS
1-05-2022
10000
50000
3
2
Groceries
Supermarkets
2
3
Hotel
Fuel
Medicine
5
3000
15-09-2021
Dining
Output:
Reward points to be credited to the Customer's account =90
Card details after payment:
AX12345, 4800,200
AB22345, 1000, 10000
CBX3323, 30000 20000
AXX2234, 37000, 13000
Sample Testcase 2:
Input
4
AX12345
Ranjan Gogol
HDFC
1-05-2021
200
5000
3
2
dining
telecom
2
2
Groceries
Supermarkets
3
3
Hotel
Fuel
Medicine
5
AB22345
Ranga Gogoi
1-05-2022
10000
11000
2
3
dining
telecom
hotel
5
2
Groceries
Supermarkets
3
CBX3323
Ranjan Gogoi
SBI
1-05-2022
20000
50000
3
2
Dining
telecom
4
2
Groceries
Supermarkets
3
3
Hotel
Fuel
Medicine
5
AXX2234
Ranjan Gogoi
Axis
1-05-2022
10000
50000
3
2
dining
telecom
3
2
Groceries
Supermarkets
2
3
Hotel
Fuel
Medicine
5
800000
15-09-2021
Air Ticket
Output:
Reward points to be credited to the Customer's account=0
Card details after payment:
AX12345, 1800,200
AB22345, 1000, 10000
CBX3323, 30000, 20000
AXX2234, 40000, 10000
IF YOU GUYS FACE ANY PROBLEM WHILE FEEL FREE TO COMMENTS DOWN YOUR QUERIES.
HOPE YOU GUYS LIKE MY WORK AND IF YOU WANT TO GET NOTIFIED IN EVERY RELEASE OF MY BLOG AND VIDEOS.PLEASE DO SUBSCRIBE TO MY CHANNEL.IT MOTIVATES ME A LOT AND FOLLOW MY BLOG TO GET ALL PREVIOUSLY ASKED QUESTIONS.CHEERS !!!!!!
2 Comments
Can you Please give the solution for above probleum
ReplyDeleteThe Output is not as per the question .
ReplyDelete