Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java The very first thing your program should do is greet the user and display some instructions, and then drop into the user input and

java
The very first thing your program should do is greet the user and display some instructions,
and then drop into the user input and processing loop. In this loop your program should
prompt the user to enter a thirteen- to sixteen-digit credit card number. The program output
for a given entry should be either a message that states that this is a valid credit card number
and also gives the type of card (VISA, MasterCard, American Express, or Discover), or state
that the number is invalid. The program should exit when the user enters a number that is
one or more zeros (in other words, 0 to exit but 00000 should also work). At that time, the
program should then state the number of each type of credit card that were valid, and the
number of invalid numbers that were entered. Note that the user can enter anything at all,
such as THISISMYNUMBER, which your program should kick back as invalid. You might
want to add a function to test that the input contains only digits before conducting any
further processing on it.
A user entry error occurs if the user enters anything other than a thirteen- to sixteen-digit
number or one (or more) zeros to exit the program. In the first case the program should
output an error message, and then continue by prompting the user for the next entry. On an
exit code the program provides the required summary information and exits.
The procedure that accepts an integer and returns the recursive sum of the digits is called
digital root. For example, the digital root of 798 is 7+9+8=24, then 2+4=6. You
should name the function that performs this operation digitalRoot. This should replace
the simpler getDigit function specified in the textbook. Your function should work with
any integer, not just a one- or two-digit number. We dont cover recursion in this class, but if
you want to write a recursive digital root function you may do so.
You have a choice as to whether you accept the input as String or long (integer). Write your
functions accordingly. Choose wisely one is (in my opinion) much easier to work with than the
other. Since this is function homework you are required to use all of the named functions given
in the textbook, even if you think of a prettier way to solve the problem. But you are free to use
String instead of long as the parameter if you choose to go that route.
Submit your Java source code and a screen shot showing your program in action processing
several entries. Start with the two CC numbers given in the textbook. Now you need to find some
more. Do not submit a screen shot using your own credit card numbers! However you can use
the algorithm to generate valid CC numbers and use those in your screen shots. It is also easy
to find lists (and generators) of valid credit card numbers that can be used for testing purposes.
Make sure there is at least one of each type (VISA, MasterCard, AMEX, and Discover). In your
screen shot, exit the program by entering two or more zeros (e.g.00000).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions