Uploaded by WR417H

ICT2611 Assignment4

advertisement
Programming Project 3 Furniture Order
Public Class Form1
Private Sub btnProcessOrder_Click(sender As Object, e As EventArgs) Handles
btnProcessOrder.Click
Dim firstAndLastName = txtCustomerName.Text
Dim address = txtAddress.Text
Dim city = txtCity.Text
Dim numOfChairs = txtNumOfChairs.Text
Dim numOfSofas = txtNumOfSofas.Text
Dim chairPrice = 350
Dim sofaPrice = 925
Dim taxRate = 0.05
Dim totalChairPrice = Integer.Parse(numOfChairs) * chairPrice
Dim totalSofaPrice = Integer.Parse(numOfSofas) * sofaPrice
Dim totalPrice = totalChairPrice + totalSofaPrice
Dim appliedTax = totalPrice * taxRate
Dim overallTotal = totalPrice + appliedTax
Dim firstAndLastNameArray = firstAndLastName.Split(",")
Dim lastNameArray = firstAndLastNameArray(1).Split("")
Dim initials = firstAndLastName.Substring(0, 2).ToUpper
Dim areaCode = city.Substring(city.Length - 4)
lstInvoice.Items.Add("Invoice Number: " + initials + areaCode)
lstInvoice.Items.Add("")
lstInvoice.Items.Add("Name: " + firstAndLastNameArray(1) + " " +
firstAndLastNameArray(0))
lstInvoice.Items.Add("Addres: " + address)
lstInvoice.Items.Add("City: " + city)
lstInvoice.Items.Add("")
lstInvoice.Items.Add("Number of chairs: " + numOfChairs)
lstInvoice.Items.Add("Number of sofas: " + numOfSofas)
lstInvoice.Items.Add("")
lstInvoice.Items.Add("
Price:
$" + totalPrice.ToString)
lstInvoice.Items.Add(" Sales Tax:
$" + appliedTax.ToString)
lstInvoice.Items.Add("
- - - - - - - - - - - - ")
lstInvoice.Items.Add("Total Price:
$" + overallTotal.ToString)
End Sub
Private Sub btnQuit_Click(sender As Object, e As EventArgs) Handles btnQuit.Click
Me.Close()
End Sub
Private Sub lstInvoice_SelectedIndexChanged(sender As Object, e As EventArgs) Handles
lstInvoice.SelectedIndexChanged
End Sub
Private Sub btnClearOrderForm_Click(sender As Object, e As EventArgs) Handles
btnClearOrderForm.Click
For Each Control In Me.Controls
If TypeName(Control) = "TextBox" Then
Control.Text = ""
End If
Next
lstInvoice.Items.Clear()
End Sub
End Class
Programming Project 7 Palindrome
Public Class Form1
Private Sub BtnPalindrome_Click(sender As Object, e As EventArgs) Handles
btnPalindrome.Click
Dim word = txtword.Text
If isPalindrome(word) Then
txtOutput.Text = "Yes"
Else
txtOutput.Text = "No"
End If
End Sub
Public Function isPalindrome(word As String) As Boolean
Dim reversedWord As String = ""
For I As Integer = word.Length To 1 Step -1
reversedWord += word.Substring(I - 1, 1)
Next
If reversedWord.ToUpper = word.ToUpper Then
Return True
Else
Return False
End If
End Function
End Class
Programming Project 2 ISBN Validator
Public Class Form1
Private Sub btnValidate_Click(sender As System.Object, e As System.EventArgs) Handles
btnValidate.Click
Dim multiples() = {10, 9, 8, 7, 6, 5, 4, 3, 2}
Dim ISBN(9) As Integer
Dim input As String = mtbISBN.Text
Dim index As Integer = 0
Dim sum As Integer
If input.Substring(12, 1).ToUpper = "X" Then
ISBN(9) = 10
sum += ISBN(9)
ElseIf IsNumeric(input.Substring(12, 1)) Then
ISBN(9) = CInt(input.Substring(12, 1))
sum += ISBN(9)
Else
MsgBox("You entered an ivalid character")
Exit Sub
End If
For i As Integer = 0 To 10
If (i <> 1 And i <> 4) Then
ISBN(index) = CInt(input.Substring(i, 1))
sum += multiples(index) * ISBN(index)
index += 1
End If
Next
If sum Mod 11 = 0 Then
txtOutput.Text = "YES"
Else
txtOutput.Text = "NO"
End If
End Sub
End Class
Download