In: Computer Science
In this project, you will create a Visual Basic solution to perform customer billing at the Cyberian Internet Cafe. Please see below for the detailed instructions. You will create the project and then design a form using the image provided here. Then, add the necessary code to do the billing calculation and display the amount due.
Instructions
In this case, you will create a Visual Basic solution that performs customer billing for the Cyberian Internet Café. The Cyberian Internet Café provides Internet access to its customers on an hourly basis. One hour of Internet access costs $12.00. You will create a solution with a splash screen, which is an application that calculates the total cost for a customer, using the image file included in the downloaded files.
Step 1: Create the Project:
Create a Visual Basic Project using the project name “InternetCafe”.
Step 2 – Design the Form:
Design the form shown in Figure 1. You will need three button controls, three text boxes, one picture box control, and five label controls. Name your controls as shown in Table 1, and set the properties as indicated.
Type of Control |
Property |
Property value |
Form |
Name |
MainForm |
Text |
Customer Billing |
|
StartPosition |
CenterScreen |
|
Label |
Name |
Label1 |
Text |
Cyberian Internet Café |
|
Font.Size |
20 |
|
Button |
Name |
calculateButton |
Text |
Calculate |
|
Button |
Name |
clearButton |
Text |
Clear |
|
Button |
Name |
exitButton |
Text |
Exit |
|
Label |
Name |
Label2 |
Text |
Last Name |
|
Label |
Name |
Label3 |
Text |
First Name |
|
Label |
Name |
Label4 |
Text |
Number of hours |
|
Label |
Name |
Label5 |
Text |
Amount due |
|
Label |
Name |
amountDueLabel |
BorderStyle |
FixedSingle |
|
BackColor |
White (web color) |
|
PictureBox |
Name |
PictureBox1 |
Size.Width |
174 |
|
Size.Height |
174 |
|
BorderStyle |
FixedSingle |
|
Image |
(use the downloaded image file |
|
TextBox |
Name |
lastNameTextBox |
TextBox |
Name |
firstNameTextBox |
TextBox |
Name |
hoursTextBox |
Table 1 – MainForm Controls and Their Property Values
Step 3 – Add the image to the project’s Debug folder:
Copy the image files (J0195384.jpg) that you downloaded as part of this Case’s files into the following folder of your project:
C:\InternetCafe\ InternetCafe\bin\Debug
(If your drive letter is different than C:, use your drive letter.)
Step 4 – Add code to perform the calculation and display the amount due:
Step 5 – Create a splash screen
Create a splash screen using the Project menu - Add Windows Form. Select the Splash Screen form template.
Also change the splash window title to "Internet Cafe". reference : textbook page 114.
Set project properties:
Set the project’s startup form to be MainForm. Set the project’s splash screen to be SplashScreen.
Step 6: Save and run
Save all files, then start the application. Try entering data and using the Calculate button. Is the result formatted as currency?
Creating Main Form:
Const HOURLY_RATE = 12.0
Dim hours As Double
Dim amount As Double
Dim isConverted As Boolean
isConverted = Double.TryParse(hoursTextBox.Text, hours)
If isConverted Then
amount = hours * HOURLY_RATE
End If
amountDueLabel.Text = Format(amount, "Currency")
Double click on clear button and add the following code:
lastNameTextBox.Text = ""
firstNameTextBox.Text = ""
hoursTextBox.Text = ""
amountDueLabel.Text = ""
Double click on the Exit button and add the following code:
Me.Close()
Creating Splash screen:
Setting project's setup:
Protected Overrides Function OnInitialize(commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean
Me.MinimumSplashScreenDisplayTime = 3000
Return MyBase.OnInitialize(commandLineArgs)
End Function
Sample output:
Code to copy :
Form1.vb:
Public Class MainForm
Const HOURLY_RATE = 12.0
Private Sub calculateButton_Click(sender As Object, e As EventArgs)
Handles calculateButton.Click
Dim hours As Double
Dim amount As Double
Dim isConverted As Boolean
isConverted = Double.TryParse(hoursTextBox.Text, hours)
If isConverted Then
amount = hours * HOURLY_RATE
End If
amountDueLabel.Text = Format(amount, "Currency")
End Sub
Private Sub clearButton_Click(sender As Object, e As EventArgs)
Handles clearButton.Click
lastNameTextBox.Text = ""
firstNameTextBox.Text = ""
hoursTextBox.Text = ""
amountDueLabel.Text = ""
End Sub
Private Sub exitButton_Click(sender As Object, e As EventArgs)
Handles exitButton.Click
Me.Close()
End Sub
End Class