Question: Please write this in Java with a scanner class. Thank you. Credit Card Number Verification Program: This program simulates the process of credit card number

Please write this in Java with a scanner class. Thank you.

Credit Card Number Verification Program:

This program simulates the process of credit card number verification process. However, note that the algorithm mentioned here is NOT the exact same algorithm companies use. First, your program should ask if the credit card is master card or visa card. Then ask the 16-digit credit card number. Then add all the digits in the credit card number and get the modulo 10 of the sum. If the modulo 10 of the summation of all the digits is zero, then its valid visa card. If the modulo 10 of the summation of all the digits is 1 then its valid MasterCard. Otherwise, the number customer has entered is an invalid card number.

For example, say the card number is 1234567867891235 and the card type entered is visa. To validate it, first add all the digits

1+2+3+4+ 5+6+7+8+ 6+7+8+9 +1+2+3+5 = 77 then get mod 10 of 77 (77%10 = 7) Since its not zero, this is not a valid visa card number

Write a Java program that reads the card type and the card number and then determine if the card number entered is a valid.

Save your program as Assignment2.java Requirements and input validation:

Card Number:

You need to read the card number as a long int. The card number should have 16 digits. If the card number does not have 16 digits, then ask the user to re-enter the number.

Card Type:

Card type must be entered as Visa or Master. If the user enter any other type, then ask the user to re- enter the card type

Sample Input and Expected System Output

Run 1:

Enter the card number : 1111111111000000 Enter the card type : Visa

This is a valid Visa card Run 2:

Enter the card number : 1111111111100000 Enter the card type : Master

This is a valid Master card Run 3:

Enter the card number : 1111111111110000 Enter the card type : Master

This is not a valid Master card

Run 4:

Enter the card number : 11111111111100002311 Card number should have 16 digits, re-enter

Enter the card number :1111222211112200

Enter the card type : Master

This is not a valid Master card Run 5:

Enter the card number :1111222211112200 Enter the card type : Amex

Invalid card type select Visa or Master Enter the card type : Visa This is a valid Visa card

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!