Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Credit card numbers follow a format to quickly determine whether the number is potentially valid. Credit card companies must generate card numbers that match the

image text in transcribed
image text in transcribed
image text in transcribed
Credit card numbers follow a format to quickly determine whether the number is potentially valid. Credit card companies must generate card numbers that match the format. When a cardholder attempts to use their card number, a retailer can check the algorithm. If it is not a valid card number, then the retailer does not need to check any further for authorization. The Prog04 CCNumGenerator Program Banks use the identical first 4 digits for all of their credit cards; these dgits identify the bank that issued the card. You will write a program that will generate a set of valid credit card numbers for a particular bank Step 1: Input. You will prompt the user to enter their 4-digit bank identifier. The user will then be prompted to specify the quantity of valid 16-digit credt card numbers that they would like generated You should prompt the user for input as follows Enter the first four digits of credit card numbers: Enter quantity of eredit card numbers to generate If a user enters an invalid value, the program should notify the user that the value entered is incorrect, and why, and prompt the user to reenter a corrected value. Step2: Calculation. The program will randomly generate the quantity of credit card numbers specified by the user, with the first 4 digits being those provided by the user To generate a valid number, we wll need to 1. Randomly generate the number 2. Test the number generated to make sure that it adheres to the correct credit card format 3. If the number fails the test, we will need to continue to generate another random number unti we find one that satisfies the required format. It may prove useful to break the credit card number into small pieces (e.g.4 numbers of 4 digits, rather than 1 number of 16 digits). The calculations neededtotest the generated number can performed on the smaller pieces and then added together to get the calculation on the full 16 digit credit card number Note: the calculations on the first 4 digits only needs to be calculated once, since it will be the same for every credt card number that we generate . We can use the formula given in class for generating a random number within a range [min,maxj min + (int)(Math.random() ((max- min)+1) A credit card number is valid if step 4 in the following check is confirmed 1. Form the sum of all digits. 2. The result is divisible by 10 For example, consider the number 4012 8888 8888 1882 1. The sum of all digits is 90. 2. 90 s divisible by 10, so the card number is valid Helpful hints Integer division (/) and remainder (%) can be used to isolate dots of an integer number * You may find that you need to repeat similar code multiple times (for example, make validation calculations on the first 4 digits, make the validation calculations on the second 4 digits, etc.). You can do this easily with some keyboard commands. To copy a chunk of code, select it and press the while pressing the cO key. To paste that same a chunk of code, place your cursor in the baton that you want t pasted to and then press the keys, holding while pressing the cV>key. Now you can make the needed minor tweaks to your pasted code Step 3: Output. The program will print out the valid credit card numbers generated Valid Credit Card Numbers Generated: 4212346231729310 4212967811827381 4212448847490724 4212764281824108 4212110033271698 4212151546052688 4212740737468230 4212493897910362 4212007218859722 4212968498084285 Helpful hint When printing our generated number, we need to be sure to print any leading zeros. For example, if our generated number is broken down into the following 4 numbers of 4 digits 4012 689 4202 35 These need to be printed with leading zeros for the 2 and 4 number: 4012068942020035 Designing, developing, and Testing Your Program Developing software is a process, you need to be following the steps: 1. 2. Develop an algorithm to solve your problem. Convert your algorithm into pseudocode

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

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

Students also viewed these Databases questions

Question

2. What is the impact of information systems on organizations?

Answered: 1 week ago

Question

Evaluate the impact of technology on HR employee services.

Answered: 1 week ago