Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can you please help provide the solution in Java? Thanks! A conversation passage between a manager and a customer in a bank will be given.
Can you please help provide the solution in Java? Thanks!
A conversation passage between a manager and a customer in a bank will be given. There will be many card numbers given in the passage. You should find the card numbers of a given card type. There are four types of cards. The card names and their number formats are given as follows. Use regex to find out the card numbers in the passage that matches the given type of card. Input Specifications: The first line consists of a string. The next line consists of the type of card to be searched. Output Specifications: A string having the numbers that match the card type with the numbers separated by a space. If the card type is not in the above mentioned list of cards, then print "Not a valid card type". Sample Input 1: Manager: Good morning, sir. How can I help you? Customer: Sir, the card names in my cards have got scratched, and I am unable to find their types. Would you be able to help me find the type using the card numbers, please? Manager: What are the types of cards you have, sir? Customer: I have Visa, American Express, Discover, and JCB cards. Manager: Okay, sir. Can I have your account number and mobile number? Customer: My account number is 1356798988878 , and my mobile number is 8765465743. Manager: Can you tell me the card numbers, sir? Customer: The card numbers are 4769856453217, 340987687654689, 213189796876789, 6011675489757876 , and 3589797987979879. Manager: Please wait a minute, sir. Customer: There are two other cards as well. The numbers are 4654465765767878 and 6589456879087568. Manager: Please give me a minute, sir. Visa Sample Output 1: 47698564532174654465765767878 Explanation: In the given passage, we have two card numbers starting with 4 and having a length of 13 and 16. Hence, we print those card numbers. Sample Input 2: Manager: Good morning, sir. How can I help you? Customer: Sir, the card names in my cards have got scratched, and I am unable to find their types. Would you be able to help me find the type using the card numbers, please? Manager: What are the types of cards you have, sir? Customer: I have Visa, American Express, Discover, and JCB cards. Manager: Okay, sir. Can I have your account number and mobile number? Customer: My account number is 1356798988878 , and my mobile number is 8765465743. Manager: Can you tell me the card numbers, sir? Customer: The card numbers are 4769856453217, 340987687654689, 213189796876789, 6011675489757876 , and 3589797987979879. Manager: Please wait a minute, sir. Customer: There are two other cards as well. The numbers are 4654465765767878 and 6589456879087568. Manager: Please give me a minute, sir. Credit Sample Output 2: Not a valid card type Explanation: The given card type is Credit, which is not one of the given card types. Therefore, "Not a valid card type" should be printed as the outputStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started