Question

What would the pseudocode be for this? The code for this has already been answered. I...

What would the pseudocode be for this? The code for this has already been answered. I need the pseudocode.

Credit card numbers typically consist of 13, 15, or 16 digits. For example, 4690 3582 1375 4657 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 specify other information such as the account number and bank number. (The precise meaning depends on the type of card.) The last digit it special; it is computed from the previous digits and is called the check digit. In (3.1.1), the check digit is 7 and is computed from the previous 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 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. Start from the right and skipping the check digit, double every other number. If the result of doubling is a two-digit number, addthe digits; otherwise, use the original digit. The other digits are not modified. 4 6 9 0 3 5 8 2 1 3 7 5 4 6 5 8 6 18 0 6 5 16 2 2 3 14 5 8 6 10 >>>>>>>>Double every other digit. 8 6 9 0 6 5 7 2 2 3 5 5 8 6 1 >>>>>>>>Add digits of two-digit numbers. Sum the resulting digits 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, AMEX, 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 the Luhn algorithm given above (use the above method not another variation) for computing a credit card check digit. There will be three parts to this project. It has to in java code. Part-1 Work the algorithm by hand. Read the description of the algorithm above and work it by hand for a credit card or 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 pseudocode that will describe how you will write you program. The conditions of the program are as follows. 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. 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. Process the credit card number and compute the check digit using the Luhn algorithm. Display output as follows. Enter a credit card number with an even number of digits: 4690358213754657 CSC-201 Computer Science I Programming Project 2 Name: Credit Card Number Entered 4690 3582 1375 4657 The check digit is 7 Once you pseudo code is complete. Upload it to Canvas. This is the second item you will turn in. Part-3 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.

Homework Answers

Answer #1

Pseudo code follows:

Prompt user for a credit card number to check
String ccString = user entered credit card number
if length (ccString) % 2 = 1 then
        inform user that card number should be even number of digits
        exit
Copy last digit in ccString to integer iCheckDigit
Declare an integer array ccIArray 
for each digit in ccString, starting from len (ccString - 1) counting down to 1
        copy digit to ccIArray

//ccIArray has the credit card digits in reverse order and does not include the check digit
for each digit in ccIArray
        if index (digit) % 2 is 1
                ccIArray [index] = ccIArray * 2
                if number of digits in ccIArray [index] is equal to 2
                        ccIArray [index] = First digit of ccIArray [index] + Second digit of ccIArray [index]
                
sumOfDigits = 0
for index in length of ccIArray
        sumOfDigits = sumOfDigits + ccIArray [index]
        
if sumOfDigits % 10 == 0
        correctCheckDigit = 0
else
        correctCheckDigit = 10 - (sumOfDigits) % 10
        
Display ccString and correctCheckDigit to user

                





Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Please code in Java and please implement constarints Digital Root and Iterations Given a non-negative integer,...
Please code in Java and please implement constarints Digital Root and Iterations Given a non-negative integer, print out its digital root and the number of iterations required to reach it. The digital root is the single digit number obtained by an iterative process of finding the sum of digits. In the next iteration, the sum of the digits in the previous iteration is computed, and the process repeated until a single digit value is obtained. Input Format The first line...
(EXCEL VBA)Write a program for a beauty store that uses an InputBox to ask the guest...
(EXCEL VBA)Write a program for a beauty store that uses an InputBox to ask the guest for a membership code. Embed this in a Do loop so that the user has to keep trying until the result is a valid membership code that starts with “Beauty” (case insensitive) and is followed by 4 digits with the final digit equal to either 6 or 8. Then use a message box to display the input promotion code and inform the user that...
write a java code. Write a program using loops to compute the sum of the 30...
write a java code. Write a program using loops to compute the sum of the 30 terms of the series below. 91/(3 + 2 + 2) + 92/(4 - 4 + 5) + 93/(5 + 6 - 8) + 94/(6 - 8 + 11) + 95/(7 + 10 + 14) + 96/(8 - 12 - 17) + . . . . Output: Term Ratio Sum 1 13 13 2 18.4 31.4 etc etc
C++ please Write code to implement the Karatsuba multiplication algorithm in the file linked in Assignment...
C++ please Write code to implement the Karatsuba multiplication algorithm in the file linked in Assignment 2 (karatsuba.cpp) in Canvas (please do not rename file or use cout/cin statements in your solution). As a reminder, the algorithm uses recursion to produce the results, so make sure you implement it as a recursive function. Please develop your code in small The test program (karatsuba_test.cpp) is also given. PLEASE DO NOT MODIFY THE TEST FILE. KARATSUBA.CPP /* Karatsuba multiplication */ #include <iostream>...
Try to write a BNF like Grammar for each one of the following constructs: - positive...
Try to write a BNF like Grammar for each one of the following constructs: - positive and negative integer numbers - floating point numbers - variable names. Notice: Recursion is needed here (use right recursion): here is an example (a grammar of two rules defines any positive integer) : Note the length in digits is not defined in this grammar, it can go recursively for ever. So we need to add another annotation (a semantic part). <positive_Number> -> <digit> |...
(SumDigits.java) Write code that asks the user to enter an integer between 100 and 999. The...
(SumDigits.java) Write code that asks the user to enter an integer between 100 and 999. The program finds and displays the three digits in the number. The program also calculates and displays the sum of the three digits. A sample run is shown below: Enter a number between 100 and 999: 528 The three digits in the number are: 5 2 8 The sum of the three digits is: 15 Note: You must use integer division and modulo division to...
write a code in python Write the following functions below based on their comments. Note Pass...
write a code in python Write the following functions below based on their comments. Note Pass is a key word you can use to have a function the does not do anything. You are only allowed to use what was discussed in the lectures, labs and assignments, and there is no need to import any libraries. #!/usr/bin/python3 #(1 Mark) This function will take in a string of digits and check to see if all the digits in the string are...
APPLIED STATISTICS 2 USE R CODE ! SHOW R CODE! Write a function to calculate the...
APPLIED STATISTICS 2 USE R CODE ! SHOW R CODE! Write a function to calculate the sum of cubes from 1 to n, but skip the multiple of 5. Say, if n=10, the result is 1^3+2^3+3^3+4^3+6^3+7^3+8^3+9^3. The input is the value of n, the output is the summation. (you need if statement to check whether a number is a multiple of 5.In R, a%%b is the remainder for a divided by b. So, we have 10%%5=0) APPLIED STATISTICS 2 USE...
(Use Java ) please write comment on every line I need to understand the code Problem...
(Use Java ) please write comment on every line I need to understand the code Problem Description: Write a program that prompts the user to enter a point (x, y) and checks whether the point is within the rectangle centered at (0, 0) with width 10 and height 5. For example, (2, 2) is inside the rectangle and (6, 4) is outside the rectangle, as shown in the Figure. (Hint: A point is in the rectangle if its horizontal distance...
=Using the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 only once,...
=Using the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 only once, find all the possible 3 digit number plus another 3 digit number to equal a 4 digit number. (No repetition of numbers is allowed.) One example is 589+437=1026. We are asked to find ALL the possibilities. I know it has to do with combinations, but I'm not quite sure if I'm using it the proper way.