Question
Write a program that asks the user to enter their full name, credit card number and a credit card charge amount. Here is an example
Write a program that asks the user to enter their full name, credit card number and a credit card charge amount.
Here is an example of what the program should look like when it runs:
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, 1011.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.
So I wrote the code where each time an invalid item is detected it loops there until a valid one is entered then it moves on to the next question. But I don't know if I interpreted the assignment wrong where after collecting the inputs, then it checks if it's wrong, and if one is wrong it says which one and then asks the user to enter all the values again and keeps doing that until all are correct instead of at each time. So I'm having a hard time figuring out how to do it the second way.
Main (1) [Java Application] /Volumes/Eclipse/Eclipse.app/Contents/Eclipse/plugins/org.eclip 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? 110. 14 You have successfully processed the payment in the amount of $110.14Step 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