CD Publisher

In this exercise, we will develop an application for a small CD publishing company. The owner wants the prices to be calculated so a customer would get a discount if he orders more. To attract customers and encourage them to order more, she has decided to fix the prices so that the customer would pay:

• \$20/CD if he orders less than 20 units
• \$15/CD if he orders less than 50 units
• \$12/CD if he orders less than 100 units
• \$8/CD if he orders less than 500 units
• \$5/CD if he orders more than 500 units
1. Start Visual Studio
2. Create a new Visual Basic Windows Application and name it CDPublisher
3. Design the form as follows:

 Control Name Text Other Properties Label Number of CDs: NumericUpDown updQuantity Maximum: 10000 TextAlign: Center Label Unit Price: TextBox txtUnitPrice 0 TextAlign: Right Label Total Price: TextBox txtTotalPrice 0 TextAlign: Right Button btnClose Close
4. Double-click the Close button and implement it as follows:

 ```Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click Close() End Sub```
5. Double-click the up down button to access its OnChange() event and implement it as follows:

 ```Private Sub updQuantity_ValueChanged(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles updQuantity.ValueChanged Dim Quantity As Integer Dim UnitPrice, TotalPrice As Double Quantity = updQuantity.Value If Quantity < 20 Then UnitPrice = 20 ElseIf Quantity < 50 Then UnitPrice = 15 ElseIf Quantity < 100 Then UnitPrice = 12 ElseIf Quantity < 500 Then UnitPrice = 8 Else UnitPrice = 5 End If TotalPrice = Quantity * UnitPrice txtUnitPrice.Text = UnitPrice.ToString("C") txtTotalPrice.Text = TotalPrice.ToString("C") End Sub```
6. Test the application
7. Close it