Question
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
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
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