
Open the Validate Number Solution.sln file contained in the VB2017\Chap07\Validate Number Solution folder. The interface provides a text box for entering a 9-digit number. The btnValidate_Click procedure should use the algorithm and example shown in Figure 7-56 to validate the user’s entry. The procedure should display a message indicating whether the entry is or is not valid. Code the procedure. Include any other code that will professionalize the interface. Save the solution and then start and test the application. Create an independent function to validate the number, pass the number as a string to the function, and have the function return a boolean (true if valid, false if invalid). Before invoking the function to validate the number, insure that the input text box contains the correct number of characters and that all the characters are numbers, and if not, display a message box informing the user to enter the correct number of characters. If the number is valid, display "Valid!" in the output label. If the number is not valid, display in red text "Not Valid!". Keep the TextAlign property of the output label MiddleCenter.
ScreenShot
-------------------------------------------------------------------------
Program
'Form name=frmValidate , Textbox name=txtNumber , button
name=btnValidate and result label name=lblValidNumber
Public Class frmValidate
'Validate button click
Private Sub btnValidate_Click(sender As Object,
e As EventArgs) Handles btnValidate.Click
'Check the entred
string's length and is digit or not,if condition false generate
error message otherwise goto next step
If
Len(Trim(txtNumber.Text)) <> 9 Or IsNumeric(txtNumber.Text) =
False Then
MsgBox("Please enter a Number with 9 characters.")
txtNumber.Clear()
txtNumber.Focus()
Exit Sub
End If
'call isValid function
to check the entered data correct or not
If
isValid(txtNumber.Text) Then
lblValidNumber.Text = "Valid!"
lblValidNumber.ForeColor = Color.Black
Else
lblValidNumber.Text = "Not Valid!"
lblValidNumber.ForeColor = Color.Red
End If
End Sub
'Function to check the entered data
validity
Private Function isValid(strNumber As String) As
Boolean
'Variables for looping ,
tempstrring generation and total sum calculation
Dim I As Integer
Dim intTemp As
Integer
Dim strTemp As
String
Dim intTot As
Integer
'loop to get each
character of the string
For I = 1 To
Len(strNumber)
'take even index numbers
If I Mod 2 = 0 Then
'convert into integer for multiplication
intTemp = Integer.Parse(Mid(strNumber, I, 1)) * 2
'if result of multiplication>9 then add digits and store
If intTemp > 9 Then
strTemp = intTemp.ToString
intTemp = Integer.Parse(Mid(strNumber, 1, 1)) +
Integer.Parse(Mid(strNumber, 2, 1))
End If
'if odd index characters convert as integer without
multiplication
Else
intTemp = Integer.Parse(Mid(strNumber, I, 1))
End If
'Calculate sum of all digits
intTot += intTemp
Next I
'Last step,find mod of
sum with 10 division,if result=0 then valid otherwise not
valid
If intTot Mod 10 = 0
Then
isValid = True
Else
isValid = False
End If
End Function
End Class
Open the Validate Number Solution.sln file contained in the VB2017\Chap07\Validate Number Solution folder. The interface provides...
Open the Gross Pay
Solution.sln file contained in the VB2017\Chap08\Gross Pay Solution
folder. The interface provides a text box for entering the number
of hours an employee worked. It also provides a list box for
selecting the employee’s pay code. The btnCalc_Click procedure
should display the gross pay, using the number of hours worked and
the pay rate corresponding to the selected code. The pay codes and
rates are listed in Figure 8-47. Employees working more than 40
hours receive...
REQUIREMENTS: Write a Graphical User Interface (GUI) program using JavaFX that prompts the user to enter a credit card number. Display whether the number is valid and the type of credit cards (i.e., Visa, MasterCard, American Express, Discover, and etc). The requirements for this assignment are listed below: • Create a class (CreditNumberValidator) that contains these methods: // Return true if the card number is valid. Boolean isValid(String cardNumber); // Get result from Step 2. int sumOfDoubleEvenPlace(String cardNumber); // Return...
I want it in C++
4. When choice 4 (Verify Your Credit Card) is selected, the program should read your credit card (for example: 5278576018410787) and verify whether it is valid or not. In addition, the program must display the type (i.e. name of the company that produced the card). Each credit card must start with a specific digit (starting digit: 1st digit from left to ight), which also is used to detemine the card type according Table 1. Table...
Please write code in
Python!
You are asked to
implement the following checksum formula to validate an identifi-
cation number given to you. The formula works as follows. Using the
original number, double the value of every other digit. Then add
the values of the individual digits together (if a doubled value
now has two digits, add the digits individually). The
identification number is valid if the resulting sum is divisible by
10. Write a function called validateID that takes...
Credit card numbers follow certain patterns. A credit card number must have between 13 and 16 digits. The number must start with the following: 4 for Visa cards 5 for MasterCard cards 37 for American Express cards 6 for Discover cards In 1954, Hans Luhn of IBM proposed an algorithm for validating credit card numbers. The algorithm is useful to determine whether a card number is entered correctly or is scanned correctly by a scanner. Almost all credit card numbers...
Please write the code in C++. This is all one question with multiple requirements. 1) Create an enumerated data type called CrdCard The types of Credit Cards to create are all 16 digits long except American Express: American Express (34 or 37), Visa (Starts with a 4), MasterCard (Starts with 51-55), Discover (Starts with 6011). 2) Create a function that takes in the enumerated type and returns a valid credit card number using the Luhn Algorithm (also called the Modulus...
Write a function called "phoneNumberFormat" that takes a string containing a ten-digit phone number (such as 5155551212) as input, convert into a more readable string with parentheses and dashes like (515)555-1212 and display it. If the input string contains more than or less than ten characters, display an error message. Note: Steps of phoneNumberFormat function can be given as follows: def phoneNumberFormat (phoneNum): 1. Let l be the length of the phoneNum 2. If 1 does not equal 10 then,...
Program Set 2 10 points) Credit card number validation Program Credit card numbers follow certain patterns: It must have between 13 and 16 digits, and the number must start with: 4 for Visa cards 5 for MasterCard credit cards 37 for American Express cards 6 for Discover cards In 1954, Hans Luhn of IBM proposed an algorithm for validating credit card numbers. The algorithm is useful to determine whether a card number is entered correctly or whether a credit card...
You are hired by a college to write a Java program to use a so-called check sum technique for catching typing errors of student ID. The college assigns a seven-digit number to each student. The seventh digit (i.e., the rightmost digit) is determined from the other digits with the use of the following formula: 7th digit = (1 *(1st digit) * 2 * (2nd digit) * ... * 6 * (6th digit)) % 10 Your program should prompt users to...
Write a Python script named assignment2.py that implements the following steps given an integer value: 1.) Double the value of every second digit beginning from the right. For example, the number 1386 has digits [1, 3, 8, 6] which become [2, 3, 16, 6]. 2.) Add the digits of the doubled values and the digits that were not doubled from the original number. For example, [2, 3, 16, 6] becomes 2 + 3 + 1 + 6 + 6 =...