K
Kenny1617
Guest
Hello everyone, this is my first post. Just need some help for an assignment that has stumped me. Would appreciate any guidance you guys can give me. I have created a majority of the assignment, but cannot configure the percentage to calculate correctly. Here's the full assignment:
"Before displaying total price, use a message box to determine whether the customer is entitled to a 10% discount for being a member of the Book Shack Book Club"
Public Class MainForm
Private Sub booksTextBox_KeyPress(sender As Object, e As KeyPressEventArgs) Handles booksTextBox.KeyPress
' accept only numbers and the Backspace key
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso
e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
Private Sub calButton_Click(sender As Object, e As EventArgs) Handles calButton.Click
' calculate the total price
Const Price1To3 As Double = 2.99
Const Price4To6 As Double = 2.49
Const PriceOver6 As Double = 1.75
Dim numBooks As Integer
Dim discount As Decimal = CInt(0.1)
Dim totalPrice As Double
Dim button As DialogResult
Dim member As DialogResult
Integer.TryParse(booksTextBox.Text, numBooks)
Select Case numBooks
Case 1 To 3
totalPrice = Price1To3 * numBooks
member = MessageBox.Show("Are you a member Of the Book Shack Book Club?", "Book Shack",
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation)
If member = DialogResult.Yes Then
totalPrice -= discount
End If
Case 4 To 6
totalPrice = Price4To6 * numBooks
member = MessageBox.Show("Are you a member Of the Book Shack Book Club?", "Book Shack",
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation)
If member = DialogResult.Yes Then
totalPrice -= discount
End If
Case Is > 6
totalPrice = PriceOver6 * numBooks
button = MessageBox.Show("$1 coupon?", "Book Shack",
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation)
If button = DialogResult.Yes Then
totalPrice -= 1
member = MessageBox.Show("Are you a member Of the Book Shack Book Club?", "Book Shack",
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation)
If member = DialogResult.Yes Then
totalPrice -= discount
End If
End If
End Select
totalLabel.Text = totalPrice.ToString("C2")
Continue reading...
"Before displaying total price, use a message box to determine whether the customer is entitled to a 10% discount for being a member of the Book Shack Book Club"
Public Class MainForm
Private Sub booksTextBox_KeyPress(sender As Object, e As KeyPressEventArgs) Handles booksTextBox.KeyPress
' accept only numbers and the Backspace key
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso
e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
Private Sub calButton_Click(sender As Object, e As EventArgs) Handles calButton.Click
' calculate the total price
Const Price1To3 As Double = 2.99
Const Price4To6 As Double = 2.49
Const PriceOver6 As Double = 1.75
Dim numBooks As Integer
Dim discount As Decimal = CInt(0.1)
Dim totalPrice As Double
Dim button As DialogResult
Dim member As DialogResult
Integer.TryParse(booksTextBox.Text, numBooks)
Select Case numBooks
Case 1 To 3
totalPrice = Price1To3 * numBooks
member = MessageBox.Show("Are you a member Of the Book Shack Book Club?", "Book Shack",
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation)
If member = DialogResult.Yes Then
totalPrice -= discount
End If
Case 4 To 6
totalPrice = Price4To6 * numBooks
member = MessageBox.Show("Are you a member Of the Book Shack Book Club?", "Book Shack",
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation)
If member = DialogResult.Yes Then
totalPrice -= discount
End If
Case Is > 6
totalPrice = PriceOver6 * numBooks
button = MessageBox.Show("$1 coupon?", "Book Shack",
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation)
If button = DialogResult.Yes Then
totalPrice -= 1
member = MessageBox.Show("Are you a member Of the Book Shack Book Club?", "Book Shack",
MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation)
If member = DialogResult.Yes Then
totalPrice -= discount
End If
End If
End Select
totalLabel.Text = totalPrice.ToString("C2")
Continue reading...