Question
PLEASE HELP! For this homework assignment you are going to create a basic credit card validator. Write a program that asks the user to enter
PLEASE HELP!
For this homework assignment you are going to create a basic credit card validator.
Write a program that asks the user to enter their full name, credit card number and a credit card charge amount. See section 5.4 in your book to learn how to use the Scanner in Java to input data.
Here is an example of what the program should look like when it runs:
What is the credit card holders name?
Robert Bruce
What is the credit card number?
4417123456789113
How much should be charged on the credit card?
110.12
You have successfully processed the payment in the amount of $110.14
You will need to validate the credit card number that a user provides. To do this I have provided you with a method already that you can copy into your program. Dont worry, you dont have to understand how this method works. You just need to figure out how to paste it into your code outside of the public static void main() method.
Copy this method into your program and use it to validate a credit card number:
You also need to validate the card holders name. Your program should store the name Robert Bruce somewhere in a variable and then check any name that is provided against the name Robert Bruce. So, if I were to use your program and put my name in Henner Mohr, your program should tell me that the name I provided was not correct.
Finally, your program should store the maximum credit card amount as $1000.00 in a variable. Your program should detect if the amount to be charged on the card is greater than this $1000.00 and then notify the user that the charge is beyond the credit max of the card. Your program should accept any values with decimal points such as 110.13, 256.85, 811.87 for amounts.
You can use the following valid credit card number to test your program:
4417123456789113
Remember to format the output correctly as seen in my output above for the amount provided for the credit card charge amount.
Also your program should loop each time an invalid item was detected. If an invalid name, or invalid credit card number or a invalid amount is used, your program should ask again to enter those values.
This means that you should collect the name, credit card charge and amount. Then check if all three of them are correct. If ANY one of them is not correct, you need to ask the user to enter all the values (name, credit card number, amount) again. You need to keep asking for these values until they get them all correct. Below is an example of what your code should look like when the user gives input that isn't valid. In this screenshot, the user entered a credit card number that isn't real.
EXAMPLE OF END RESULTS
What is the credit card holder's full name? Robert Bruce What is the credit card number? 1234123412341234 How much should be charged on the credit card? 100.59 You entered an invalid name or a credit card number or an amount. Please try again. What is the credit card holder's full name? Robert Bruce What is the credit card number? 4417123456789113 How much should be charged on the credit card? 100 You have successfully processed the payment in the amount of $100.00
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started