MAIN METHOD IS ALREADY PROVIDED AND CANT BE CHANGED ANY HELP

MAIN METHOD IS ALREADY PROVIDED AND CAN\'T BE CHANGED. ANY HELP WOULD BE AWESOME, THANKS!!

1. Description
Credit card numbers follow certain patterns. A credit card number must have between 13 and 16 digits. It must start with:

4 for Visa cards
5 for Master cards
37 for American Express cards 6 for Discover cards

In 1954, Hans Luhn of IBM proposed an algorithm for validating credit card numbers. The algorithm is useful to determine whether a card number is entered correctly or whether a credit card is scanned correctly by a scanner. All credit card numbers are generated following this va- lidity check, commonly known as the Luhn check or the Mod 10 check, which can be described as follows (for illustration, consider the card number 4388576018402626):

Double every second digit from right to left. If the doubling of a digit results in a two-digit number, add up the two digits to get a single-digit number.
2*2= 4
2*2= 4

4*2= 8
1*2= 2
6 * 2 = 12 (1 + 2 = 3) 5 * 2 = 10 (1 + 0 = 1) 8 * 2 = 16 (1 + 6 = 7) 4*2= 8

Now add all single-digit numbers from Step 1. 4 + 4 + 8 + 2 + 3 + 1 + 7 + 8 = 37

Add all digits in the odd places from right to left in the card number. 6 + 6 + 0 + 8 + 0 + 7 + 8 + 3 = 38

Sum the results from Step 2 and Step 3. 37 + 38 = 75

If the result from Step 4 is divisible by 10, the card number is valid; otherwise, it is invalid. For example, the number 4388576018402626 is invalid, but the number 4388576018410707 is valid.

Finish writing the CCValidator.java code given to you on ilearn. YOU ARE NOT ALLOWED to touch the main method. In the main method are tests to determine if all the code you have written is correct. Make Sure to name your Project CCValidator to make things easier. To make this assignment easier it may to implement the functions in the following order (since the test will execute in this order):

getSize getPrefix(code given) prefixMatched

1

getDigit sumOfOddPlace sumOfDoubleEvenPlace isValid

You are also welcome to write helper functions if you feel you need them. Following Methods can be used to write your program:

Example Output:

Submission

Submit a java source file named CCValidator.java to ilearn in the assignment 8 section.

Problem Source

Liang, Daniel Y., Introduction to Java Programming, Comprehensive Version, 8th edition, ISBN 0132130807.

Solution

main()
{
int i,temp1=0,temp2=0,sum;
//int evo[2];
long double cc_no[16];
cout<<\"enter the cc no:\";
for(i=1;i<=16;i++)
{
cin>>cc_no[i];
}


for(i=15;i>=1;i=i-2) //sum of odd no
{
if(cc_no[i]<=9)
{
cc_no[i]=cc_no[i]+cc_no[i];
}
else
{
  
}
}
for(i=16;i>=2;i=i-2) // sum of even no
{
temp2=temp2+cc_no[i];
}
sum=temp1+temp2;

if(sum%10==0)
{
cout<<\"card acceptable\";
}
else
{
cout<<\"card not orinal\";
}
}

MAIN METHOD IS ALREADY PROVIDED AND CAN\'T BE CHANGED. ANY HELP WOULD BE AWESOME, THANKS!! 1. Description Credit card numbers follow certain patterns. A credit
MAIN METHOD IS ALREADY PROVIDED AND CAN\'T BE CHANGED. ANY HELP WOULD BE AWESOME, THANKS!! 1. Description Credit card numbers follow certain patterns. A credit

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site