E3 Home Page - CIST1z x CengageBrain My x Bcokshelf Programn Bookshelf: A Guide
ID: 3684393 • Letter: E
Question
E3 Home Page - CIST1z x CengageBrain My x Bcokshelf Programn Bookshelf: A Guide t xG Computer Science q .), ChlIps://cengageu'ain.vilelsource.com/4/bours/978 1285667355/1,4921/4/4@0.00:56.2 x have at least one connection. Use two functions: one to calculate and return the total due for business customers, and the other to calculate and return the total due for residential customers. The form's FormClosing event procedure should verify that the user wants to close the application. Code the application. Save the solution and then start and test the application. Close the Code Editor window and then close the solution. Cable Direct O Business Premium channels: Connections IstPremi IstCon Residential Total due: Calculate Total Due Exit Figure 7-52 User interface for Exercise 6 306 AM " @f.ill! :) 3th AM 4/1/2016Explanation / Answer
Main Form.Designer.vb
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmMain
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.radBusiness = New System.Windows.Forms.RadioButton()
Me.radResidentian = New System.Windows.Forms.RadioButton()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.lstPremium = New System.Windows.Forms.ListBox()
Me.lstConnections = New System.Windows.Forms.ListBox()
Me.Label3 = New System.Windows.Forms.Label()
Me.txtSummaryAndPrice = New System.Windows.Forms.TextBox()
Me.btnCalculate = New System.Windows.Forms.Button()
Me.btnExit = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'radBusiness
'
Me.radBusiness.AutoSize = True
Me.radBusiness.Location = New System.Drawing.Point(42, 52)
Me.radBusiness.Name = "radBusiness"
Me.radBusiness.Size = New System.Drawing.Size(75, 21)
Me.radBusiness.TabIndex = 0
Me.radBusiness.TabStop = True
Me.radBusiness.Text = "&Business"
Me.radBusiness.UseVisualStyleBackColor = True
'
'radResidentian
'
Me.radResidentian.AutoSize = True
Me.radResidentian.Location = New System.Drawing.Point(42, 91)
Me.radResidentian.Name = "radResidentian"
Me.radResidentian.Size = New System.Drawing.Size(89, 21)
Me.radResidentian.TabIndex = 1
Me.radResidentian.TabStop = True
Me.radResidentian.Text = "Residential"
Me.radResidentian.UseVisualStyleBackColor = True
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(180, 48)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(116, 17)
Me.Label1.TabIndex = 2
Me.Label1.Text = "&Premium channels:"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(343, 48)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(82, 17)
Me.Label2.TabIndex = 3
Me.Label2.Text = "&Connections:"
'
'lstPremium
'
Me.lstPremium.FormattingEnabled = True
Me.lstPremium.ItemHeight = 17
Me.lstPremium.Location = New System.Drawing.Point(183, 69)
Me.lstPremium.Name = "lstPremium"
Me.lstPremium.Size = New System.Drawing.Size(104, 89)
Me.lstPremium.TabIndex = 4
'
'lstConnections
'
Me.lstConnections.FormattingEnabled = True
Me.lstConnections.ItemHeight = 17
Me.lstConnections.Location = New System.Drawing.Point(346, 69)
Me.lstConnections.Name = "lstConnections"
Me.lstConnections.Size = New System.Drawing.Size(104, 89)
Me.lstConnections.TabIndex = 5
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(39, 196)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(147, 17)
Me.Label3.TabIndex = 6
Me.Label3.Text = "Summary and total due:"
'
'txtSummaryAndPrice
'
Me.txtSummaryAndPrice.Location = New System.Drawing.Point(42, 217)
Me.txtSummaryAndPrice.Multiline = True
Me.txtSummaryAndPrice.Name = "txtSummaryAndPrice"
Me.txtSummaryAndPrice.ReadOnly = True
Me.txtSummaryAndPrice.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.txtSummaryAndPrice.Size = New System.Drawing.Size(535, 153)
Me.txtSummaryAndPrice.TabIndex = 7
'
'btnCalculate
'
Me.btnCalculate.Location = New System.Drawing.Point(488, 69)
Me.btnCalculate.Name = "btnCalculate"
Me.btnCalculate.Size = New System.Drawing.Size(89, 38)
Me.btnCalculate.TabIndex = 8
Me.btnCalculate.Text = "&Calculate"
Me.btnCalculate.UseVisualStyleBackColor = True
'
'btnExit
'
Me.btnExit.Location = New System.Drawing.Point(488, 120)
Me.btnExit.Name = "btnExit"
Me.btnExit.Size = New System.Drawing.Size(89, 38)
Me.btnExit.TabIndex = 9
Me.btnExit.Text = "E&xit"
Me.btnExit.UseVisualStyleBackColor = True
'
'frmMain
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(7.0!, 17.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(640, 419)
Me.Controls.Add(Me.btnExit)
Me.Controls.Add(Me.btnCalculate)
Me.Controls.Add(Me.txtSummaryAndPrice)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.lstConnections)
Me.Controls.Add(Me.lstPremium)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.radResidentian)
Me.Controls.Add(Me.radBusiness)
Me.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Margin = New System.Windows.Forms.Padding(3, 4, 3, 4)
Me.Name = "frmMain"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Cable Direct"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents radBusiness As System.Windows.Forms.RadioButton
Friend WithEvents radResidentian As System.Windows.Forms.RadioButton
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents lstPremium As System.Windows.Forms.ListBox
Friend WithEvents lstConnections As System.Windows.Forms.ListBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents txtSummaryAndPrice As System.Windows.Forms.TextBox
Friend WithEvents btnCalculate As System.Windows.Forms.Button
Friend WithEvents btnExit As System.Windows.Forms.Button
End Class
Main Form.vb
Public Class frmMain
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Load the listboxes
For intPremium As Integer = 0 To 20
lstPremium.Items.Add(intPremium.ToString)
Next
For intConnect As Integer = 0 To 100
lstConnections.Items.Add(intConnect.ToString)
Next
End Sub
Private Function GeTotal(ByVal dblProcess As Double,
ByVal dblConnect As Double,
ByVal dblChannels As Double) As Double
Dim dblTotal As Double
dblTotal = dblProcess + dblConnect + dblChannels
Return dblTotal
End Function
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
Const strTABLE_Header As String = "Service" & vbTab & "Price" & vbTab & "Quantity" & vbTab & "Subtotal" & vbNewLine
Const strSEPARATOR = "___________________________________________________________________________" & vbNewLine
Const strHEADER_MESSAGE As String = "Cable Direct" & vbNewLine & "125 New Road Ave." & vbNewLine & "Miami, FL. 33256" & vbNewLine
Dim dblFeeProcessing As Double
Dim dblFeeBasic As Double
Dim dblFeePremium As Double
Dim dblFeeTotal As Double
Dim intChannels As Integer
Dim intConnections As Integer
Integer.TryParse(lstPremium.SelectedItem.ToString, intChannels)
Integer.TryParse(lstConnections.SelectedItem.ToString, intConnections)
' Check if this is a residential or busines
If radBusiness.Checked Then
dblFeeProcessing = 16.5
' Check if there is more than 10 connections
If intConnections <= 10 Then
dblFeeBasic = intConnections * 8.0
Else
dblFeeBasic = 80.0 + (intConnections - 10) * 4
End If
dblFeePremium = intChannels * 50.0
' Calculate the total using a function
dblFeeTotal = GeTotal(dblFeeProcessing, dblFeeBasic, dblFeePremium)
Else 'residential is selected
dblFeeProcessing = 4.5
dblFeeBasic = 30
dblFeePremium = intChannels * 5
dblFeeTotal = GeTotal(dblFeeProcessing, dblFeeBasic, dblFeePremium)
End If
'Generate the message
txtSummaryAndPrice.Text = strTABLE_Header & strHEADER_MESSAGE & strSEPARATOR
End Sub
End Class
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.