this program uses a StringBuilder to record the code abd uses String functions and regular expression to validate the information for the customer
JFrame Java
This program to demonstrate Strings , the String Builder and Regular Expression
this program accepts codes entered into a textbox , use a StringBuilder to record the codes and uses String Functions and a Regular Expression to validate the information for the customer's credit card number
Content 220/2020 1.Create a Java Windows application. Change the idlebar to the name of the company you get to decide this yourself on this lab.) 2. Add Textboxes for a Code Scanned and Credit Card to Verify. Create labels with these textboxes to tell the user what they are 3.Place 3 buttons on the frame. One toscan' a code (add it to the StringBuilder if it passes) one to Verify the credit card, and one to Display the log (of the codes.) 4. Create 2 StringBuilders named: strBidrog (or bufforcodes if you like...but give it a descriptive name in any case), and strBidrails (or bufferFails) as class level variables (so it will remember the values between button presses.) (Note: It is not clear in the text. But, here is the deal with strings and string builders (and why you are going to use them here to work with them.) A string is used for most string objects in an oo language of this type. It saves memory by allowing multiple uses of the same word like "John to all share the same reference and have only one place in memory they all use in something called the "String Pool in the area of memory that stores objects. This increased memory efficiency and program speed.) But... this actually slows down the application the same set of characters is being modified constantly and stored in one location...because the application searches for a match in the string pool and either finds one or not, and if not it must call on the string constructor to create a new one. It is more efficient if you have something that is not being used multiple paces and changing all the time to use an actual Buffer type data structure like a StringBuilder if it is going to be modified constantly by the program. In this program It's being used to keep a transaction log on the device.) 5. Under an action Performed event handler for the Scan button have it validate the code typed into that textfield. Use String methods from chapter 16 to make sure the code value typed by the user into its textbox is exactly 8 characters long and does not contain a space. If it passed validation.... Append the first three characters (lots say they are control codes, just to allow you to demonstrate a different set of String methods out of this chapter without writing 2 programs)...to the StringBuilder recording the codes that pass in the order they were put in If it fails validation... Insert the complete entry into the StringBuilder recording the ones that do not pass so the last one entered is the first one inside it. 6. Add code to handle a button click on the second button for the credit card verifier. (You can do this by using one action performed for all the buttons and checking the source or by creating separate event handlers. It's up to you.) The code for this button should use a Regular Expression to test the value in the textbox. The valid format and range of values is: 4 sets of 4 digits separated by dashes, the leading digit in the first group cannot be the second group of digits are each in the range of 1-3 (they are control numbers indicating the type of card.) If the credit card number is not in a valid format...give a JOptionPane message box or show a message in a JLabel so the user can see that the number entered is not a valid card number. Example: 1234-1122-7474-1234 is a valid card number. 222-22-222, 0111-1111-1111-1111, and b123-5555-1111-1111 are not valid card numbers. Hint: The pattern for checking a phone number is very similar and is shown in the chapter. 7. The third button should show the current values in the two StringBuilders for the user. (Remember one had the first three characters of the ones that pass in the order they were put in, and the second one has the ones that failed in the order oftast entered.) 2/26/2020 Content 1.Create a Java Windows application. Change the title bar to the name of the company (you get to decide this yourself on this lab.) 2. Add Textboxes for a Code Scanned and Credit Card to Verify. Create labels with these textboxes to tell the user what they are. 3.Place 3 buttons on the frame. One to 'scan' a code (add it to the StringBuilder if it passes), one to Verify the credit card, and one to Display the log (of the codes.) 4.Create 2 StringBuilders named: strBldrlog (or buffercodes if you like...but give it a descriptive name in any case), and strBidrFails (or bufferFails) as class level variables (so it will remember the values between button presses.) (Note: It is not clear in the text. But, here is the deal with strings and string builders (and why you are going to use them here to work with them.) A string is used for most string objects in an Oo language of this type. It saves memory by allowing multiple uses of the same word like "John' to all share the same reference and have only one place in memory they all use in something called the 'String Pool in the area of memory that stores objects. (This increased memory efficiency and program speed.) But...this actually slows down the application if the same set of characters is being modified constantly and stored in one location...because the application searches for a match in the string pool, and either finds one or not, and if not it must call on the string constructor to create a new one. It is more efficient if you have something that is not being used multiple paces and changing all the time to use an actual Buffer type data structure like a StringBuilder if it is going to be modified constantly by the program. In this program it's being used to keep a transaction log on the device.) But, here lost string obie the same res objects,aders is weer sinds one not being u be me 5. Under an actionPerformed event handler for the Scan button have it validate the code typed into that textfield. Use String methods from chapter 16 to make sure the code value typed by the user into its textbox is exactly 8 characters long and does not contain a space. If it passed validation.... Append the first three characters (lets say they are control codes, just to allow you to demonstrate a different set of String methods out of this chapter without writing 2 programs) to the StringBuilder recording the codes that pass in the order they were put in. If fails validation... Insert the complete entry into the StringBuilder recording the ones that do not pass so the last one entered is the first one inside it. 6.Add code to handle a button click on the second button for the credit card verifier. (You can do this by using one action performed for all the buttons and checking the source or by creating separate event handlers. It's up to you.) The code for this button should use a Regular Expression to test the value in the textbox. The valid format and range of values is: 4 sets of 4 digits separated by dashes, the leading digit in the first group cannot be the second group of digits are each in the range of 1-3 [they are control numbers indicating the type of card.] If the credit card number is not in a valid format...give a JOptionPane message box or show a message in a JLabel so the user can see that the number entered is not a valid card number. Example: 1234-1122-7474-1234 is a valid card number. 222-22-222.0111.1111.1111-1111 and 123-5555-1111-1111 are not valid card numbers Hint: The pattern for checking a phone number is very similar and is shown in the chapter 7. The third button should show the current values in the two StringBuilders for the user. (Remember one had the first three characters of the ones that pass in the order they were put in, and the second one has the ones that failed in the order oftast entered.) Content 220/2020 1.Create a Java Windows application. Change the idlebar to the name of the company you get to decide this yourself on this lab.) 2. Add Textboxes for a Code Scanned and Credit Card to Verify. Create labels with these textboxes to tell the user what they are 3.Place 3 buttons on the frame. One toscan' a code (add it to the StringBuilder if it passes) one to Verify the credit card, and one to Display the log (of the codes.) 4. Create 2 StringBuilders named: strBidrog (or bufforcodes if you like...but give it a descriptive name in any case), and strBidrails (or bufferFails) as class level variables (so it will remember the values between button presses.) (Note: It is not clear in the text. But, here is the deal with strings and string builders (and why you are going to use them here to work with them.) A string is used for most string objects in an oo language of this type. It saves memory by allowing multiple uses of the same word like "John to all share the same reference and have only one place in memory they all use in something called the "String Pool in the area of memory that stores objects. This increased memory efficiency and program speed.) But... this actually slows down the application the same set of characters is being modified constantly and stored in one location...because the application searches for a match in the string pool and either finds one or not, and if not it must call on the string constructor to create a new one. It is more efficient if you have something that is not being used multiple paces and changing all the time to use an actual Buffer type data structure like a StringBuilder if it is going to be modified constantly by the program. In this program It's being used to keep a transaction log on the device.) 5. Under an action Performed event handler for the Scan button have it validate the code typed into that textfield. Use String methods from chapter 16 to make sure the code value typed by the user into its textbox is exactly 8 characters long and does not contain a space. If it passed validation.... Append the first three characters (lots say they are control codes, just to allow you to demonstrate a different set of String methods out of this chapter without writing 2 programs)...to the StringBuilder recording the codes that pass in the order they were put in If it fails validation... Insert the complete entry into the StringBuilder recording the ones that do not pass so the last one entered is the first one inside it. 6. Add code to handle a button click on the second button for the credit card verifier. (You can do this by using one action performed for all the buttons and checking the source or by creating separate event handlers. It's up to you.) The code for this button should use a Regular Expression to test the value in the textbox. The valid format and range of values is: 4 sets of 4 digits separated by dashes, the leading digit in the first group cannot be the second group of digits are each in the range of 1-3 (they are control numbers indicating the type of card.) If the credit card number is not in a valid format...give a JOptionPane message box or show a message in a JLabel so the user can see that the number entered is not a valid card number. Example: 1234-1122-7474-1234 is a valid card number. 222-22-222, 0111-1111-1111-1111, and b123-5555-1111-1111 are not valid card numbers. Hint: The pattern for checking a phone number is very similar and is shown in the chapter. 7. The third button should show the current values in the two StringBuilders for the user. (Remember one had the first three characters of the ones that pass in the order they were put in, and the second one has the ones that failed in the order oftast entered.) 2/26/2020 Content 1.Create a Java Windows application. Change the title bar to the name of the company (you get to decide this yourself on this lab.) 2. Add Textboxes for a Code Scanned and Credit Card to Verify. Create labels with these textboxes to tell the user what they are. 3.Place 3 buttons on the frame. One to 'scan' a code (add it to the StringBuilder if it passes), one to Verify the credit card, and one to Display the log (of the codes.) 4.Create 2 StringBuilders named: strBldrlog (or buffercodes if you like...but give it a descriptive name in any case), and strBidrFails (or bufferFails) as class level variables (so it will remember the values between button presses.) (Note: It is not clear in the text. But, here is the deal with strings and string builders (and why you are going to use them here to work with them.) A string is used for most string objects in an Oo language of this type. It saves memory by allowing multiple uses of the same word like "John' to all share the same reference and have only one place in memory they all use in something called the 'String Pool in the area of memory that stores objects. (This increased memory efficiency and program speed.) But...this actually slows down the application if the same set of characters is being modified constantly and stored in one location...because the application searches for a match in the string pool, and either finds one or not, and if not it must call on the string constructor to create a new one. It is more efficient if you have something that is not being used multiple paces and changing all the time to use an actual Buffer type data structure like a StringBuilder if it is going to be modified constantly by the program. In this program it's being used to keep a transaction log on the device.) But, here lost string obie the same res objects,aders is weer sinds one not being u be me 5. Under an actionPerformed event handler for the Scan button have it validate the code typed into that textfield. Use String methods from chapter 16 to make sure the code value typed by the user into its textbox is exactly 8 characters long and does not contain a space. If it passed validation.... Append the first three characters (lets say they are control codes, just to allow you to demonstrate a different set of String methods out of this chapter without writing 2 programs) to the StringBuilder recording the codes that pass in the order they were put in. If fails validation... Insert the complete entry into the StringBuilder recording the ones that do not pass so the last one entered is the first one inside it. 6.Add code to handle a button click on the second button for the credit card verifier. (You can do this by using one action performed for all the buttons and checking the source or by creating separate event handlers. It's up to you.) The code for this button should use a Regular Expression to test the value in the textbox. The valid format and range of values is: 4 sets of 4 digits separated by dashes, the leading digit in the first group cannot be the second group of digits are each in the range of 1-3 [they are control numbers indicating the type of card.] If the credit card number is not in a valid format...give a JOptionPane message box or show a message in a JLabel so the user can see that the number entered is not a valid card number. Example: 1234-1122-7474-1234 is a valid card number. 222-22-222.0111.1111.1111-1111 and 123-5555-1111-1111 are not valid card numbers Hint: The pattern for checking a phone number is very similar and is shown in the chapter 7. The third button should show the current values in the two StringBuilders for the user. (Remember one had the first three characters of the ones that pass in the order they were put in, and the second one has the ones that failed in the order oftast entered.)