Instructions In this case, you will create a Visual Basic solution that simulate
ID: 658501 • Letter: I
Question
Instructions
In this case, you will create a Visual Basic solution that simulates a program running on a kiosk. This program allows Buzz Advertising to generate ad sales for its weekly shopping deals booklet in a local flea market. Merchants can book their own ads by using this program. This program uses objects created from classes. Use the accompanying graphic file and the instructions below.
Requirements:
Ad price is based on the size of the ad and the location in the shopping deals booklet. Table 1 shows the ad sizes and the price relationship of each size to the base price. Table 2 shows the location markup that must be applied to the calculated price to determine the final price. Prices are calculated as follows:
<price is determined by size> * <markup> = finalprice
The base price of an ad is $225.00.
Restrictions:
Business card size ads may only be placed on interior pages. Do not allow the user to selection any location when interior page location is selected.
The outside back cover is reserved for a full page ad. Do not allow the user to select outside back cover unless full page has already been selected.
Size
Price
Full page
100% of base price
Half page
65% of base price
Quarter page
40% of base price
Business card
$35.00
Table 1 Price by Size
Location
Markup
Interior page
1.00
Inside front cover
1.20
Inside back cover
1.15
Outside back cover
1.40
Table 2 Markup by Location
Step 1: Create the Project:
Create a Visual Basic Project using the project name BuzzAdvertising.
Step 2 Design the Form:
Design the form as shown in Figure 1. You will need three button controls, eight radio buttons, two group boxes, seven labels, and one picture box. Load the downloaded bee.jpg image into the picture box. Remove the control box because this program will run in a kiosk.
Step 3 Create the Ad class
Add a Class file named Ad to the project. The Ad class should have the following properties: company, telephone, run date, size, location, and price. Create a method in the Ad class that calculates the final price of an ad.
Step 4 Write code in the main form:
Set the size and location based on the radio button selections. Create a new Ad object, passing in the required data values to the constructor. After the Ad object has been created, call the Ad objects calculate method to obtain the final price. Display the final price with appropriate formatting.
Step 7 Finish up:
Be sure to add the code for the Clear and Exit buttons.
Step 8: Save and run
Save all files, then start the application.
Size
Price
Full page
100% of base price
Half page
65% of base price
Quarter page
40% of base price
Business card
$35.00
Explanation / Answer
Public Class Form1
Private Sub
Form1_Load(ByVal sender
As
System.Object,
ByVal
e As
System.EventArgs)
Handles MyBase.Load
End Sub
Private Sub
reserveButton_Click(ByVal sender
As
System.Object,
ByVal
e
As System.EventArgs)
Handles revsButton.Click
Dim ad As Ad_to_project
If halfRadioButton.Checked = True Then
backRdButton.Enabled = False
End If
If quaterRdButton.Checked = True Then
outsidebackRdButton.Enabled = False
End If
If BuisnessRdButton.Checked = True Then
insidefrontRdButton.Enabled = False
insidebackRdButton.Enabled = False
outsidebackRdButton.Enabled = False
End If
If companyTextBox.Text = String.Empty AndAlso TelephoneTextBox.Text = String.Empty AndAlso dateTextBox.Text = String.Empty Then
MessageBox.Show(" You must enter all information", "Buzz Advertising", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If fullRdButton.Checked = True Then
ad.Size = 225.0
End If
If halfRdButton.Checked = True Then
ad.Size = 225.0 * 0.65
End If
If quaterRdButton.Checked = True Then
ad.Size = 225.0 * 0.4
End If
If BuisnessRdButton.Checked = True Then
ad.Size = 35.0
End If
If outsidebackRdButton.Checked = True Then
ad.Location = 1.4
End If
If insidebackRadioButton.Checked = True Then
ad.Location = 1.15
End If
If insidefrontRdButton.Checked = True Then
ad.Location = 1.2
End If
If interiorRdButton.Checked = True Then
ad.Location = 1.0
End If
priceLabel.Text = ad.Price.ToString("C2")
End Sub
Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Close()
End Sub
End Class
Private Sub reserveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles reserveButton.Click
Dim ad As New Ad_to_project
If outsidebackRadioButton.Checked = False AndAlso insidebackRadioButton.Checked = False AndAlso insidefrontRadioButton.Checked = False AndAlso interiorRadioButton.Checked = False Then
MessageBox.Show("You must choose a location", "Buzz Advertising", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
End If
If companyTextBox.Text = String.Empty
AndAlso TelephoneTextBox.Text = String.Empty
AndAlso dateTextBox.Text = String.Empty Then
MessageBox.Show(" enter all informations",
"Buzz Advertising",
MessageBoxButtons.OK,
MessageBoxIcon.Information)
Exit Sub
End If
If fullRdButton.Checked = True The
ad.Size = 225.0
End If
If halfRdButton.Checked = True Then
ad.Size = 225.0 * 0.65
End If
If quaterRdButton.Checked = True Then
ad.Size = 225.0 * 0.4
End If
If BuisnessRdButton.Checked = True Then
ad.Size = 35.0
End If
If outsidebackRdButton.Checked = True Then
ad.Location = 1.4
ElseIf insidebackRdButton.Checked = True Then
ad.Location = 1.15
ElseIf insidefrontRdButton.Checked = True Then
ad.Location = 1.2
ElseIf interiorRdButton.Checked = True Then
ad.Location = 1.0
End If
priceLabel.Text = ad.Price.ToString("C2")