Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CODE = Option Explicit On Option Strict On Option Infer Off Public Class MainFor

ID: 3762261 • Letter: C

Question

CODE =

Option Explicit On
Option Strict On
Option Infer Off

Public Class MainForm


'-------------------------------------------------------------------------------------------------------------------------------------------------

' Sub procedure to define exitButton click event.

Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Close()
End Sub


'-------------------------------------------------------------------------------------------------------------------------------------------------

' Sub procedure to select existing text of the firstFourTextBox.

Private Sub firstFourTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles firstFourTextBox.Enter
firstFourTextBox.SelectAll()
End Sub


'-------------------------------------------------------------------------------------------------------------------------------------------------

' Sub procedure to allows only numbers and the Backspace key for the firstFourTextBox.

Private Sub firstFourTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles firstFourTextBox.KeyPress

If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub

'-------------------------------------------------------------------------------------------------------------------------------------------------

' Sub procedure clear the content of the firstFourTextBox.

Private Sub firstFourTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles firstFourTextBox.TextChanged
creditNumberLabel.Text = String.Empty
End Sub


'-------------------------------------------------------------------------------------------------------------------------------------------------

' Sub procedure to define creditNumberButton click event (Determines the fifth digit in a credit card number).
Private Sub creditNumberButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles creditNumberButton.Click

' 1. Declare two String variables called creditNum, fifthDigit and an integer variable called sumOfDigits within the following space.
  


' 2. Write code to get the value at firstFourTextBox to the variable creditNum within the following space.

' 3. Fill the two blanks in following statement to check whether the creditNum is a four digit string.
If creditNum _ _ _ _ _ _ _ _ Then

' 4. Write code to get the summation of four digits in variable creditNum to the variable sumOfDigit within the following space.
' Steps:
' Take each string digit using Substring function.
' Use Convert.ToInt32 function to convert each string digit to an integer. Syntax of Convert.ToInt32 is as follows.
' int a = Convert.ToInt32(string)
' Get the summation according to the given scenario (First digit + 3*Second digit + Third digit + 3*Fourth digit)

' 5. Write code to find the fifth digit and store in the variable fifthDigit within the following space.

' 6. Write code to append fifth digit to first four digits in the variable creditNum within the following space.

Else ' processed when the user does not enter four digits
MessageBox.Show("Please enter a four-digit number.", "Georgetown Credit", MessageBoxButtons.OK, MessageBoxIcon.Information)

End If

firstFourTextBox.Focus()
End Sub
End Class

Each credit card number issued by Vita Credit contains five digits. The last digit is determined by multiplying the second and fourth digit by three and then adding the products to the first and third digits. The last digit in the sum is then appended to the first four digits in the credit card number, as illustrated in following figure Fifth Digit Algorithm First four digits in credit card number: Step 1: Multiply the second and forth digits by 3 21 Step 2: Add the numbers together +21 36 Step 3: Take the last digit in the sum and append it to the first four digits, resulting in the final credit card number: 13576 In this assignment, you are required to complete the given incomplete application which takes four digits and then calculate the fifth digit and display the credit card number. The name of the solution, project, and form file are Vita Solution, Vita Project, and Main Form.vb, respectively

Explanation / Answer

declare two variables an an integer:

Imports System.Runtime.CompilerServices
Dim creditNum As Int
Dim creditNumtext As Int
Dim fifthDigit As Int
Dim fifthDigittext As Int
Dim sumOfDigits As Int
Dim i As Int

creditNumtext=TextBox1.TextLength
creditNum=creditNumtext.GetNumericValue(creditNumtext)
fifthDigittext=TextBox2.TextLength
fifthDigit=fifthDigittext.GetNumericValue(fifthDigittext)


if creditNum <>4
MsgBox("credit number must be equal to 4")
end if

public Sub creditcard(creditNum as Integer,fifthDigit as Integer,sumOfDigits as Integer)
console.Writeline(sumOfDigits)
End sub

Sub Main()
int creditNum:=creditNum
int fifthDigit:=fifthDigit

for i from 0 to creditNum-1{

int creditNum:=integer(creditNum[i])
int fifthDigit:=integer(fifthDigit[i])
sumOfDigits:=fifthDigit+creditNum
}

end sub

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote