Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

-6.31 (Financial: credir cand number validarion) Credit card numbers follow certain patterns. A credit card number mast have between 13 and 16 digits, It must

image text in transcribed
image text in transcribed
-6.31 (Financial: credir cand number validarion) Credit card numbers follow certain patterns. A credit card number mast have between 13 and 16 digits, It must start with 7 4 for Visa cards - 5 for Master cards - 37 for Anserican Experss cards E 6 for Discover cards. In 1954. Hans Luhn of IBM proposed an algorithm for validatiog credit card numbers. The algorithm is useful to determine whether a cand number is entered correctly, or whether a credit card is scanned correctly by a scanner, Credit card numbers are generated following this validity check, commonly known as the Zuhn check or the Mod 10 check, which can be described as follows ffor itlustration, consider the cand number 4385576018402626 ): 1. Double every second digit from right to Icft. If doubling of a digit results in a two-digit number, add up the two digits to fot a Ningle digit number. 5. If the reralt from Siep 4 is divisible by 10, the cand number is valid; othernise, it is invalid. For example, the namber 4388576018402626 is invalut, bet the number 4385576018410707 is valid. Write a program that prompts the user to enter a credit cand number as a 7 ong integer. Display whether the number is valis or invalid. Desigs your progam to use the following mecthodh: I's feturn true if the card nusber is valid %f. publie atatie boolean isvalid(1ong nueber) i" oet the result froe bted z." publie statie int sueorboublalivenelace(leng nuaber) jou Return this mubber if it is a single digit. otheraise, " return the sus of the two digits "\% public static int getbigit (int nuaber) ov Weturn sun of odd-place aigits in munter public static int sunoroddPlace(leng nunter) fo faturn true if the peaber of is a pritfo far nyaber +l. public static boelean prefixhatched(long nunber, ist d). in. Hoturi the ninter of gigits in do? gublic statie fat getsize(lang d) for Boturn the firat in nusber of digits. fran mobre if the public statie long getpretix(long nuaberg int k ). Here are sample ruas of the prugrant. (Viss may atw implensene ithis program by -6.31 (Financial: credir cand number validarion) Credit card numbers follow certain patterns. A credit card number mast have between 13 and 16 digits, It must start with 7 4 for Visa cards - 5 for Master cards - 37 for Anserican Experss cards E 6 for Discover cards. In 1954. Hans Luhn of IBM proposed an algorithm for validatiog credit card numbers. The algorithm is useful to determine whether a cand number is entered correctly, or whether a credit card is scanned correctly by a scanner, Credit card numbers are generated following this validity check, commonly known as the Zuhn check or the Mod 10 check, which can be described as follows ffor itlustration, consider the cand number 4385576018402626 ): 1. Double every second digit from right to Icft. If doubling of a digit results in a two-digit number, add up the two digits to fot a Ningle digit number. 5. If the reralt from Siep 4 is divisible by 10, the cand number is valid; othernise, it is invalid. For example, the namber 4388576018402626 is invalut, bet the number 4385576018410707 is valid. Write a program that prompts the user to enter a credit cand number as a 7 ong integer. Display whether the number is valis or invalid. Desigs your progam to use the following mecthodh: I's feturn true if the card nusber is valid %f. publie atatie boolean isvalid(1ong nueber) i" oet the result froe bted z." publie statie int sueorboublalivenelace(leng nuaber) jou Return this mubber if it is a single digit. otheraise, " return the sus of the two digits "\% public static int getbigit (int nuaber) ov Weturn sun of odd-place aigits in munter public static int sunoroddPlace(leng nunter) fo faturn true if the peaber of is a pritfo far nyaber +l. public static boelean prefixhatched(long nunber, ist d). in. Hoturi the ninter of gigits in do? gublic statie fat getsize(lang d) for Boturn the firat in nusber of digits. fran mobre if the public statie long getpretix(long nuaberg int k ). Here are sample ruas of the prugrant. (Viss may atw implensene ithis program by

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions

Question

Question What are the advantages of a written bonus plan?

Answered: 1 week ago