You are on page 1of 2

Public Class Form1

02

Private Sub btnComplete_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles btnComplete.Click

03

'This calculates and displays each floors occupancy rate.

04

Const MAX_FLOOR As Integer = 8

05

Const ROOMS_PER_FLOOR As Integer = 30

06

Dim occupancy As Integer

07

Dim occupancySum As Integer = 0

' Occupancy count


' Total Occupancy count

08
09

' Calculate the occupancy rate for each floor, the total of all
occupancy rates, and the total rooms occupied.

10

lstOutput.Items.Clear()

11

For floor As Integer = 1 To MAX_FLOOR

12

occupancy = CInt(InputBox("Please enter the number of rooms" &


vbCrLf & "occupied on floor " & floor))

13
14
15
16

occupancySum += occupancy
lstOutput.Items.Add("Floor " & floor & " is " & (occupancy /
ROOMS_PER_FLOOR) * 100 & "% full.")
Next
lstOutput.Items.Add("Total occupancy is " & occupancySum & " rooms
- " & (occupancySum / (ROOMS_PER_FLOOR * MAX_FLOOR)) * 100 & "% full.")

17
18

End Sub

19
20
21

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnExit.Click

22
23

'This exits the application.

24
25
26

Me.Close()
End Sub

27
28

Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles btnClear.Click


29

'This procedure clears all labels and list box.

30

lstOutput.Items.Clear()

31

lblOccupancyRate.Text = String.Empty

32

lblTotalOccupied.Text = String.Empty

33

End Sub

34 End Class

You might also like