Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Credit card numbers typically consist of 13, 15, or 16 digits. For example, 4690 3582 1375 4657 (3.1.1) is a hypothetical credit card number.

 

Credit card numbers typically consist of 13, 15, or 16 digits. For example, 4690 3582 1375 4657 (3.1.1) is a hypothetical credit card number. The first digit designates the system. In (3.1.1), the first digit, 4, shows that the card would be a Visa card. The following digits spec- ify other information such as the account number and the bank number. (The precise meaning depends on the type of card.) The last digit is special; it is computed from the preceding digits and is called a check digit. In (3.1.1), the check digit is 7 and is com- puted from the preceding digits 4690 3582 1375 465. Credit card check digits are used to identify certain erroneous card numbers. It is not a security measure, but rather it is used to help detect errors such as giving a credit card number over the phone and having it transcribed improperly or detecting an error in entering a credit card number while ordering a product online. The check digit is computed as follows. Starting from the right and skipping the check digit, double every other number. If the result of doubling is a two-digit num- ber, add the digits; otherwise, use the original digit. The other digits are not modified. 5465 035 8 21 3 7 Double every other digit. 14 5 8 6 10 469 8 6 18 0 6 5 16 2 2 3 869 065 7 223 5 5 86 1 Sum the resulting digits Add digits of two-digit numbers. 8+6+9+0+6+5+7+2+2+3+5+5+8+6+1= 73. If the last digit of the sum is 0, the check digit is 0. Otherwise, subtract the last digit of the sum from 10 to get the check digit, 10-3 = 7. Verify the check digit on your favorite Visa, MasterCard, American Express, or Diners Club card. This method of calculating a check digit is called the Luhn algorithm. It is named after Hans Peter Luhn (1896- 1964), who invented it while at IBM. Although originally patented, it is now in the public domain and is widely used. For this project you will write a program that implements Luhn Algorithm for computing the a credit card check digit. There will be three parts to this project. Part-1 Work the algorithm by hand. Read the description of the algorithm above and work it by hand for a credit card debit card number you might have. You can use the hypothetical credit card number in the discussion above. Compute the credit card check digit by hand. Write out the steps neatly. Do it several times until you understand how it works. Write it up neatly, scan it and upload to Canvas. This will be the first of three items to turn in this project. Part-2 Write up a program algorithm (pseudo code). Once you understand the algorithm write pesudo code that will describe how you will write you program. The conditions of the program might have. You can use the hypothetical credit card number in the discussion above. Compute the credit card check digit by hand. Write out the steps neatly. Do it several times until you understand how it works. Write it up neatly, scan it and upload to Canvas. This will be the first of three items to turn in this project. Part-2 Write up a program algorithm (pseudo code). Once you understand the algorithm write pesudo code that will describe how you will write you program. The conditions of the program are as follows. 1. The program should accept as input the a credit card number. Since the credit card numbers are typically 16 digits you will have to load it into a string since a 16 digit card number is too big for an integer. 2. The program should check the number digits in the card numbed and verify the number is an even number. If the number of digits is even then continue processing. If the number of digits is odd issue a message to that affect and exit the program. 3. Process the credit card number and compute the check digit using the Luhn algorithm. 4. Display output as follows. Enter a credit card number with an even number of digits: 4690358213754657 Part-3 CSC-201 Computer Science I Programming Project 2 Name: Credit Card Number Entered 4690 3582 1375 4657 The check digit is 7 5. Once you pseudo code is complete. Upload it to Canvas. This is the second item you will turn in. Use you pseudo code to help you code the program in Java. Test your program using credit card number above (4690358213754657) Test it with other credit card numbers you might have. Once you have the code completed and tested upload the source java file to canvas. This is the third of three items you will turn in.

Step by Step Solution

3.40 Rating (156 Votes )

There are 3 Steps involved in it

Step: 1

LuhnAlgorithmjava Java program to implement Luhn Algorithm to calculate the check digit of a credit ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Computer Engineering questions