Results 1 to 9 of 9

Thread: [RESOLVED] Nee help with code

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2011
    Posts
    5

    Resolved [RESOLVED] Nee help with code

    I am new to coding, I am also having a serious issue with finishing this project. Could I please get some help.

    the Galaxy Hotel asks you to write a Windows application that computes the occupancy rate of the hotel. Occupancy rate is a percentage that is equal to the number of rooms sold divided by the total number of rooms available. The hotel has seven floors. tThe user should use an Input Box function to respond to two questions about each floor: How many rooms are occupied on that floor? How many rooms on the floor are vacant? Display which floor you are asking about in each question. Display how many rooms are occupied and vacant on each floor in a List Box object. After the user has entered all the information, display the following results: the total number of rooms at the hotel, the number of occupied rooms, and the number of vacant rooms. Also display the occupancy rate as a percentage, such as 61%. Non-numeric values should not be accepted. Do not accept negative numbers. Publish the application after testing.


    so far i have this for my code:
    vb.net Code:
    1. Public Class frmHotelOccupancy
    2.  
    3.     Private Sub btnOccupancyInformation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOccupancyInformation.Click
    4.         ' The btnOccupancyInformation click event accepts and displays up to thirty rooms
    5.         ' from the user, and then calculates and displays the % of occupancy.
    6.  
    7.         ' Declare and Initialze variables
    8.         Dim decOccupiedRooms As Decimal
    9.         Dim strOccupiedRooms As String
    10.         Dim decTotalRooms As Decimal = 10
    11.         Dim strTotalRooms As String = CStr(0)
    12.         Dim intTotalRooms As Integer = 0
    13.         Dim intTotalOccupied As Integer = 0
    14.         Dim intTotalVacant As Integer = 0
    15.         Dim intVacant As Integer = 0
    16.         Dim decOccupancyRate As Decimal
    17.         Dim strInputMessage As String = "Enter # of occupied rooms"
    18.         Dim strInputHeading As String = "Occupancy Percent"
    19.         Dim strNormalMessage As String = "Enter # of occupied rooms"
    20.         Dim strNonNumericError As String = "ERROR - Enter a # of rooms occupied"
    21.         Dim strNegativeError As String = "ERROR - Enter a positive # of occupied rooms"
    22.         Dim intFloor As Integer
    23.         For intFloor = 1 To 7
    24.            
    25.         Next
    26.  
    27.         ' Declare and intialize loop variables
    28.         Dim strCancelClick As String = ""
    29.         Dim intMaxNumberOfEntries As Integer = 6
    30.         Dim intMinNumberOfEntries As Integer = 0
    31.  
    32.         ' This loop allows the user to enter the room information (vacany or occupied)
    33.         ' up to 10 rooms, and 7 floors. The loop terminates when the user has entered
    34.         ' 10 rooms per 7 floors or clicks the Cancel button or the Close button in the InputBox.
    35.  
    36.         strOccupiedRooms = InputBox(strInputMessage & intTotalOccupied, strInputHeading, " ")
    37.  
    38.         Do Until intTotalOccupied > intMaxNumberOfEntries Or strOccupiedRooms = strCancelClick
    39.  
    40.             If IsNumeric(strTotalRooms) Then
    41.                 decOccupiedRooms = Convert.ToDecimal(strOccupiedRooms)
    42.                 If decOccupiedRooms > 0 Then
    43.                     lstVacancyAndOccupancy.Items.Add(decOccupiedRooms)
    44.                     decOccupiedRooms += decOccupancyRate
    45.                     intTotalOccupied += 1
    46.                     strInputMessage = strNormalMessage
    47.                 Else
    48.                     strInputMessage = strNegativeError
    49.                 End If
    50.             Else
    51.                 strInputMessage = strNonNumericError
    52.             End If
    53.  
    54.             If intTotalOccupied <= intMaxNumberOfEntries Then
    55.                 strTotalRooms = InputBox(strInputMessage & intTotalRooms, strInputHeading, " ")
    56.             End If
    57.  
    58.         Loop
    59.  
    60.         'Makes label visible
    61.         lblPercentage.Visible = True
    62.  
    63.         ' Calculate and display pecentage of occupied rooms
    64.         If intTotalOccupied > -1 Then
    65.             decOccupancyRate = decOccupiedRooms / (decTotalRooms)
    66.             lblPercentage.Text = "Percentage of rooms occupied " & _
    67.                 decOccupancyRate.ToString("F1") & "%"
    68.         Else
    69.             lblPercentage.Text = "No room occupancy entered"
    70.         End If
    71.  
    72.         'Display the Enter Room Information button
    73.         btnOccupancyInformation.Enabled = False
    74.  
    75.     End Sub
    Last edited by Hack; Dec 15th, 2011 at 06:51 AM. Reason: Added Highlight Tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width