Question

In: Computer Science

Please use Visual Basic Hotel Occupancy The Hotel has 8 Floors and 30 rooms on each...

Please use Visual Basic

Hotel Occupancy

The Hotel has 8 Floors and 30 rooms on each floor. Create an application that calculates the occupancy rate for each floor, and the overall occupancy rate for the hotel. The occupancy rate is the percentage of rooms occupied, and may be calculated by dividing the number of rooms occupied by the number of rooms.

For example, if 18 rooms on the 1st floor are occupied, the Occupancy Rate is as follows:

18/30=0.6 or 60%

For the Overall Occupancy Rate, using the above example,

18/(8*30)=0.075 or 7.5%

Another example for Overall Occupancy Rate:

If 1st floor, 18 rooms occupied.

2nd floor, 30 rooms occupied, then the calculation is:

(18+30) /(8*30)   or (18+30)/240 =0.2 or 20%

You will need to use Name Constants for Rooms (30 rooms), and Floors (8 floors).

Some variables and Constants you will need to declare in class level to do the Overall Total and Overall Occupancy Rate calculation.

Some variables you will need to use in the local level.

The application’s form should appear similar to the one shown below.

In the form load event handler, use a loop to populate floor 1 to 8 in combo box. (Do NOT create floor 1 to 8 at design time using the Items property)

On startup, “Select the floor” combo box should default to floor 1. Each time the user enters the occupancy for a single floor and clicks the Save button, the floor number in the Drop-Down List ComboBox should increment automatically (just add 1 to its SelectedIndex property), and a new line should appear in the ListBox with the percentage occupancy. Also, the contents of the TextBox at the top of the form should clear automatically when the user clicks the Save button, so the user does not accidentally enter the same data twice in a row.

The Restart button should clear all the appropriate controls on the form. “Select the floor” combo box should default to floor 1.

The Exit button should end the application.

The Save button should do all input validation and all other calculations. (Do NOT use a loop in the btnSave_click event handler)

Input Validation: Be sure to check for a non-integer value in TextBox using the Integer.TryParse method and notify the user if there is an error. Since each floor has only 30 rooms, you need to do the range check to prevent user enter a value is greater than 30 or a negative number. A zero is allowed to input since it may have no occupancy for the whole floor.

Use the values below to confirm that your application is performing the correct calculations.

Use access key for all buttons’ control.   

Solutions

Expert Solution

Below is the solution:

Public Class frmMain
    Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        txtRate.Enabled = False 'disable the textbox to enter the data on form load
        txtRooms.Enabled = False 'disable the textbox to enter the data on form load
        cmbFloor.Enabled = False 'disable the combobox
        cmbFloor.Text = 1 ''first time set the text to 1
        For n = 1 To 8 'add the combox value using for loop
            cmbFloor.Items.Add(n)
        Next
    End Sub

    Dim Floor As Integer = 1 ''set the floor to 1
    Dim occupancy As Integer         ' Occupancy count
    Dim occupancySum As Integer = 0 ' Total Occupancy count
    Private Sub btnComplete_Click(sender As Object, e As EventArgs) Handles btnComplete.Click
        'This calculates and displays each floors occupancy rate.
        Const maximumFloors As Integer = 8 ''declare the number of floor
        Const maximumRooms As Integer = 30 ''set the floor of each room to 30
        If Floor <= 8 Then ''Check for the 8 floor not more than 8 entry
            If Not Integer.TryParse(txtNoOfRooms.Text, occupancy) Then ''check for the integer input
                MessageBox.Show("Enter Number of Rooms Integer only ")

            ElseIf occupancy > 30 Or occupancy < 0 Then ''check for the textbox of room entry must be 0-30
                MessageBox.Show("Enter Number of Rooms 1 to 30 only ")
            Else
                occupancySum += occupancy ''sum of entered room for each floor
                ListBox1.Items.Add("Floor: " & Floor & " Rooms Occupied: " & occupancy & " Occupancy Rate: " & Math.Round((occupancy / maximumRooms) * 100, 2) & "%") 'display the each room occupancy to the listbox

                If Floor <= 8 Then ''check for the floor less that or equal 8
                    cmbFloor.Text = Floor + 1
                    Floor += 1
                End If
                If Floor = 9 Then ''check if the floor value has 9 then show the combobx to 8
                    cmbFloor.Text = 8
                End If
                txtRooms.Text = occupancySum.ToString ''display the rooms textbox occupancy
                txtRate.Text = Math.Round((occupancySum / (maximumRooms * maximumFloors)) * 100, 2).ToString ''
                txtNoOfRooms.Text = "" 'set the textbox room to empty
            End If

        Else
            MsgBox("Total floor is calculated Please Reset for new.")
        End If
        txtNoOfRooms.Select() 'focus the textbox room

    End Sub

    Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
        'This procedure clears all labels and list box.
        occupancySum = 0 ''rest the occupancy sum of each floor rooms
        txtNoOfRooms.Text = "" ''set the textbox of the room to empty
        txtRate.Text = "" ''set the rate to empty
        txtRooms.Text = "" ''set the rooms to empty
        txtNoOfRooms.Select() 'focus on room textbox
        Floor = 1 'set the floor to 1
        cmbFloor.Text = 1 'set the combobox to 1
        ListBox1.Items.Clear() ''çlear the listbox
        ListBox1.Text = String.Empty 'set the listbox string to empty
    End Sub

    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        Me.Close() '"close the application
    End Sub
End Class

sample output:


Related Solutions

Write a program that calculates the occupancy rate for a hotel. The program should start by asking the user how many floors the hotel has.
Use JAVAProgram #1: Hotel Occupancy: Write a program that calculates the occupancy rate for a hotel. The program should start by asking the user how many floors the hotel has. A for loop should then iterate once for each floor. In each iteration of the for loop, the program should ask the user for the number of rooms of the floor and how many of them are occupied. After all of the iterations are complete the program should display how...
Write a program that calculates the occupancy rate for each floor of a hotel. (Use a...
Write a program that calculates the occupancy rate for each floor of a hotel. (Use a sentinel value and please point out the sentinel in bold.) The program should start by asking for the number of floors in the hotel. A loop should then iterate once for each floor. During each iteration, the loop should ask the user for the number of rooms on the floor and the number of them that are occupied. After all the iterations, the program...
A motel has 30 rooms and expects 70% occupancy next year. • The owners’ investment is...
A motel has 30 rooms and expects 70% occupancy next year. • The owners’ investment is 520,000, and they expect a 12% after tax return on their investment.(Net Income) • The income tax rate is 24%. • The motel has two mortgages: the first in the amount of $259,000 at a 10% interest rate and the second of $240,000 at a 14% interest rate. • Present value of the building is $432,000 and the depreciation rate is 5%. • The...
30. A popular resort hotel has 300 rooms and is usually fully booked. About 7% of...
30. A popular resort hotel has 300 rooms and is usually fully booked. About 7% of the time a reservation is canceled before the 6:00 p.m. deadline with no penalty. What is the probability that at least 285 rooms will be occupied? Use the binomial distribution to find the exact value.
IN JAVA Write a program that calculates the occupancy rate for each floor of a hotel....
IN JAVA Write a program that calculates the occupancy rate for each floor of a hotel. (Use a sentinel value and please point out the sentinel in bold.) The program should start by asking for the number of floors in the hotel. A loop should then iterate once for each floor. During each iteration, the loop should ask the user for the number of rooms on the floor and the number of them that are occupied. After all the iterations,...
The Typhoon Resort, which has 100 rooms, has currently been experiencing an occupancy dip to a...
The Typhoon Resort, which has 100 rooms, has currently been experiencing an occupancy dip to a 60.00% level. The current rack rate is $80.00 with a marginal cost of $20.00 per room. The management of this resort would like to see the options when they apply $10.00 and 10.00% discounts from the current rack rate separately. Based on these two discount situations, what equivalent occupancy percentages must be achieved to maintain the same levels of contribution margin for both $10.00...
The Harriet Hotel in downtown Boston has 100 rooms that rent for $150 per night. It costs the hotel $30 per room in variable costs
In Crystal BallThe Harriet Hotel in downtown Boston has 100 rooms that rent for $150 per night. It costs the hotel $30 per room in variable costs (cleaning, bathroom items, etc.) each night a room is occupied. For each reservation accepted, there is a 5% chance that the guest will not arrive. If the hotel overbooks, it costs $200 to compensate guests whose reservations cannot be honored.How many reservations should the hotel accept if it wants to maximize the average...
suppose that a hotel has 100 rooms and the hotel is accepting overbooking anticipating some cancellations....
suppose that a hotel has 100 rooms and the hotel is accepting overbooking anticipating some cancellations. The probability for cancellation is 0.07. a) What is the probability that somoen who made a reservation will be turned away if this hotel has allowed for 110 resevations? b. 105 reservation c. why did the answer to part b go down
Q4 Hotel California has 160 rooms. The hotel has an ample low-fare demand at the room...
Q4 Hotel California has 160 rooms. The hotel has an ample low-fare demand at the room rate of $200 per night, but the demand from the high-fare class which pays $450 per night on average, is uncertain. Table below shows the number of high-fare rooms that were booked during the past 30 days. How many rooms should Hotel California protect for high-fare customers to maximize its expected revenue? (6 points) Number of high-fare rooms Frequency 0 5 1 3 2...
Avila Hotel has 300 rooms and charges $120 per room. The hotel estimates that the demand...
Avila Hotel has 300 rooms and charges $120 per room. The hotel estimates that the demand for the rooms follows a uniform distribution between 270 and 330 each day. Reservations may be canceled by 6pm with no penalty. The hotel estimates that 3% of the reservations are canceled by 6pm. Hence, the hotel allows overbooking by 20 room (the hotel allows up to 320 customers to make reservation). When more customers arrive than can be handled (e.g., more than 300...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT