CUM Books need a program to calculate a customer’s total book price and the discount given to the customer Accept the customer’s name, type of customer and the discount given. Calculate the total book price bought by the customer based on the customer’s relationship with CUM Books. Assume that the price of one book is R5500 User-interface specifications: Input Specifications: • Accept the customer’s relationship with CUM Books using three radio buttons. The type of customer can be: Regular, Non-regular or Passers-by (Store “R”, “N” or “P” respectively for the type of customer). • Use appropriate controls for the other input value(s). • Provide a button that the user must click to process the data and display the output
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmCUMBooks
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.rbRegular = New System.Windows.Forms.RadioButton()
Me.Label1 = New System.Windows.Forms.Label()
Me.btnCalculate = New System.Windows.Forms.Button()
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.rbPassersBy = New System.Windows.Forms.RadioButton()
Me.rbNonRegular = New System.Windows.Forms.RadioButton()
Me.txtCustomerName = New System.Windows.Forms.TextBox()
Me.Label3 = New System.Windows.Forms.Label()
Me.txtTotalBookPrice = New System.Windows.Forms.TextBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.txtDiscount = New System.Windows.Forms.TextBox()
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'rbRegular
'
Me.rbRegular.AutoSize = True
Me.rbRegular.Checked = True
Me.rbRegular.Location = New System.Drawing.Point(35, 28)
Me.rbRegular.Name = "rbRegular"
Me.rbRegular.Size = New System.Drawing.Size(62, 17)
Me.rbRegular.TabIndex = 0
Me.rbRegular.TabStop = True
Me.rbRegular.Text = "Regular"
Me.rbRegular.UseVisualStyleBackColor = True
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(26, 20)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(136, 13)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Enter the customer’s name:"
'
'btnCalculate
'
Me.btnCalculate.Location = New System.Drawing.Point(168, 225)
Me.btnCalculate.Name = "btnCalculate"
Me.btnCalculate.Size = New System.Drawing.Size(100, 23)
Me.btnCalculate.TabIndex = 2
Me.btnCalculate.Text = "Calculate"
Me.btnCalculate.UseVisualStyleBackColor = True
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.rbPassersBy)
Me.GroupBox1.Controls.Add(Me.rbNonRegular)
Me.GroupBox1.Controls.Add(Me.rbRegular)
Me.GroupBox1.Location = New System.Drawing.Point(29, 56)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(239, 108)
Me.GroupBox1.TabIndex = 3
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Select the type of customer "
'
'rbPassersBy
'
Me.rbPassersBy.AutoSize = True
Me.rbPassersBy.Location = New System.Drawing.Point(35, 74)
Me.rbPassersBy.Name = "rbPassersBy"
Me.rbPassersBy.Size = New System.Drawing.Size(76, 17)
Me.rbPassersBy.TabIndex = 0
Me.rbPassersBy.TabStop = True
Me.rbPassersBy.Text = "Passers-by"
Me.rbPassersBy.UseVisualStyleBackColor = True
'
'rbNonRegular
'
Me.rbNonRegular.AutoSize = True
Me.rbNonRegular.Location = New System.Drawing.Point(35, 51)
Me.rbNonRegular.Name = "rbNonRegular"
Me.rbNonRegular.Size = New System.Drawing.Size(80, 17)
Me.rbNonRegular.TabIndex = 0
Me.rbNonRegular.TabStop = True
Me.rbNonRegular.Text = "Non-regular"
Me.rbNonRegular.UseVisualStyleBackColor = True
'
'txtCustomerName
'
Me.txtCustomerName.Location = New System.Drawing.Point(168, 17)
Me.txtCustomerName.Name = "txtCustomerName"
Me.txtCustomerName.Size = New System.Drawing.Size(100, 20)
Me.txtCustomerName.TabIndex = 4
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(26, 202)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(105, 13)
Me.Label3.TabIndex = 1
Me.Label3.Text = "The total book price:"
'
'txtTotalBookPrice
'
Me.txtTotalBookPrice.Location = New System.Drawing.Point(168, 199)
Me.txtTotalBookPrice.Name = "txtTotalBookPrice"
Me.txtTotalBookPrice.ReadOnly = True
Me.txtTotalBookPrice.Size = New System.Drawing.Size(100, 20)
Me.txtTotalBookPrice.TabIndex = 4
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(26, 173)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(102, 13)
Me.Label2.TabIndex = 1
Me.Label2.Text = " The book discount:"
'
'txtDiscount
'
Me.txtDiscount.Location = New System.Drawing.Point(168, 170)
Me.txtDiscount.Name = "txtDiscount"
Me.txtDiscount.ReadOnly = True
Me.txtDiscount.Size = New System.Drawing.Size(100, 20)
Me.txtDiscount.TabIndex = 4
'
'frmCUMBooks
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(299, 261)
Me.Controls.Add(Me.txtTotalBookPrice)
Me.Controls.Add(Me.txtDiscount)
Me.Controls.Add(Me.txtCustomerName)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.btnCalculate)
Me.Controls.Add(Me.Label1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmCUMBooks"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "CUM Books"
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox1.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents rbRegular As System.Windows.Forms.RadioButton
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents btnCalculate As System.Windows.Forms.Button
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents txtCustomerName As System.Windows.Forms.TextBox
Friend WithEvents rbPassersBy As System.Windows.Forms.RadioButton
Friend WithEvents rbNonRegular As System.Windows.Forms.RadioButton
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents txtTotalBookPrice As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents txtDiscount As System.Windows.Forms.TextBox
End Class
Public Class frmCUMBooks
'the price of one book is R5500
Private Const BOOK_PRICE As Double = 5500
''' <summary>
''' Calculate button
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim discountPercent As Double = 0D
Dim discount As Double = 0D
Dim totalBookPrice As Double
If rbRegular.Checked Then
discountPercent = 0.2D
End If
If rbPassersBy.Checked Then
discountPercent = 0.1D
End If
discount = BOOK_PRICE * discountPercent
totalBookPrice = BOOK_PRICE - discount
txtDiscount.Text = "R" + discount.ToString("N")
txtTotalBookPrice.Text = "R" + totalBookPrice.ToString("N")
End Sub
End Class
Comments
Leave a comment