Hotel Occupancy formHelp

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2009
Posts: 8
Reputation: hhh0505 is an unknown quantity at this point 
Solved Threads: 1
hhh0505 hhh0505 is offline Offline
Newbie Poster

Hotel Occupancy formHelp

 
0
  #1
22 Days Ago
i'm new to visual basic and I managed to make somewhat of an assignment I need. now it's not perfect but, I am terrible when it comes to calculations... what am I doing wrong? ;-;

' This procedure calculates and displays each floors
' occupancy rate.

Dim intCount As Integer ' Loop counter
Dim decoccupancy As Decimal ' occupancy rate

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

For intCount = 0 To intMAX_floor = 250
decoccupancy = introoms(intCount) * decroom_occupancy_RATE
decoccupancyrate(intCount) = decoccupancy
decTotaloccupancyrate /= decoccupancy
intTotalrooms &= Int(intCount)

it's telling me to divie the number of rooms by the occupied rooms... 18/30 = .6 or 60%
and the hotel has 240 rooms

Not sure wat direction to go in now.... Thanks
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 8
Reputation: hhh0505 is an unknown quantity at this point 
Solved Threads: 1
hhh0505 hhh0505 is offline Offline
Newbie Poster
 
0
  #2
22 Days Ago
this is what i have so far can someone help pelaseee?
  1. Public Class Form1
  2.  
  3. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
  4.  
  5.  
  6. Me.Close()
  7. End Sub
  8.  
  9. Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
  10.  
  11. 'This procedure clears all labels and list box.
  12.  
  13. ListBox1.Items.Clear()
  14. lblOccupancyRate.Text = String.Empty
  15. lblTotalRooms.Text = String.Empty
  16.  
  17. End Sub
  18.  
  19. Private Sub btnReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReport.Click
  20.  
  21.  
  22. 'This calculates and displays each floors occupancy rate.
  23. Dim decOccupancy As Array
  24. Dim decTotalOccupancyRate As Decimal
  25. Dim strUserInput As String
  26. Dim decTotalOccupancy As Decimal
  27. Dim intCount As Integer
  28. 'ListBox1.Items.Add
  29.  
  30. 'Calculate the occupancy rate for each floor, the total of all occupancy rates, and the total rooms occupied.
  31. For intCount As Integer = 0 To 7
  32. strUserInput = InputBox("Enter the number of rooms occupied. Provide a value")
  33. decOccupancy(intCount) = CDec(strUserInput) / 30
  34. ListBox1.Items.Add(decOccupancy(intCount))
  35. decTotalOccupancy += CDec(strUserInput)
  36. Next
  37. Do
  38. ListBox1.Items.Add(decTotalOccupancy)
  39. ListBox1.Items.Add(decTotalOccupancy / 240)
  40. Loop
  41.  
  42. If CInt(strUserInput) > 30 Then
  43. MessageBox.Show("Please enter a number greater than 0 and less than 30")
  44. End If
  45.  
  46. 'Display the running total.
  47. lblOccupancyRate.Text = decTotalOccupancyRate.ToString("c")
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 8
Reputation: hhh0505 is an unknown quantity at this point 
Solved Threads: 1
hhh0505 hhh0505 is offline Offline
Newbie Poster
 
0
  #3
22 Days Ago
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.
When the user clicks the "Complete Report" button, a loop should execute and iterate 8 times. Each time the loop iterates, it should display an input box for one of the hotel's floors. The input box should ask the user to enter the number of rooms occupied on that floor. As the user enters a value for each floor, the loop should calculate the occupancy rate for that floor, and display the information for that floor in the list box. When the number of occupied rooms has been entered for all the floors, the application should display the total number of rooms occupied and the overall occupnacy rate of the hotel.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 42
Reputation: kplcjl is an unknown quantity at this point 
Solved Threads: 5
kplcjl kplcjl is offline Offline
Light Poster
 
0
  #4
22 Days Ago
1. You can't add rates, it just doesn't work
2. When you display percentages, multiply by 100
3. You are processing and THEN checking for user errors and doing nothing about it.
Instead force them to get it right before going on.
4. Don't assume the user entered correct data
5. Keeping track of the occupancy per floor makes more sense than the rate

How about this? (Used notepad so it may be a bit weird.):
  1. 'This calculates and displays each floors occupancy rate.
  2. Dim Occupancy(7) As Byte 'Why do you have an array that is going to be dropped
  3. Dim TotOccupancy As Byte = 0 '240 is < 255 - can't overflow
  4. Dim decOccupancyRate As Decimal
  5. Dim strUserInput As String
  6. Dim decOccupancy As Decimal
  7. Dim intCount As Byte
  8. Dim RoomCount As Integer 'User can say 2 billion and shouldn't overflow
  9. 'ListBox1.Items.Add
  10.  
  11. For intCount As Integer = 0 To 7
  12. RoomCount = 0
  13. while RoomCount < 1 or RoomCount > 30
  14. strUserInput = InputBox("Enter the number of rooms occupied. Provide a value")
  15. if isnumeric(strUserInput) then RoomCount = strUserInput
  16. if RoomCount < 1 or RoomCount > 30 then
  17. MessageBox.Show("Please enter a number greater than 0 and less than 30")
  18. End If
  19. end while
  20. Occupancy(intCount) = RoomCount
  21. TotOccupancy += RoomCount
  22. decOccupancyRate = CDec(RoomCount) / 30.
  23. ListBox1.Items.Add(decOccupancyRate*100)
  24. Next
  25. strUserInput = "Total occupancy= " & TotOccupancy.ToString()
  26. ListBox1.Items.Add(strUserInput)
  27. decOccupancyRate = CDec(TotOccupancy) / 240.
  28. ListBox1.Items.Add(decOccupancyRate * 100)
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 42
Reputation: kplcjl is an unknown quantity at this point 
Solved Threads: 5
kplcjl kplcjl is offline Offline
Light Poster
 
0
  #5
22 Days Ago
Whoops set the count to -1 and check for less than 0.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 8
Reputation: hhh0505 is an unknown quantity at this point 
Solved Threads: 1
hhh0505 hhh0505 is offline Offline
Newbie Poster
 
0
  #6
22 Days Ago
bah its not working...thing is i dont thing we r suppose to use bytes in this assignment...im so frustrated right now... Main problem now is cant to string to Integer and Byte to integer... Could i use Double insetad of byte? thign part where i cant String to integar is bolded
'This calculates and displays each floors occupancy rate.
        Dim Occupancy(7) As Byte 'Why do you have an array that is going to be dropped
        Dim TotOccupancy As Byte = 0 '240 is < 255 - can't overflow
        Dim decOccupancyRate As Decimal
        Dim strUserInput As String
        Dim decOccupancy As Decimal
        Dim Count As Byte
        Dim RoomCount As Integer 'User can say 2 billion and shouldn't overflow
        'ListBox1.Items.Add

        For intCount As Integer = 0 To 7
            RoomCount = 0
            While RoomCount < 1 Or RoomCount > 30
                strUserInput = InputBox("Enter the number of rooms occupied. Provide a value")
                If IsNumeric(strUserInput) Then RoomCount = strUserInput
                If RoomCount < 1 Or RoomCount > 30 Then
                    MessageBox.Show("Please enter a number greater than 0 and less than 30")
                End If
            End While
            Occupancy(intCount) = RoomCount
            TotOccupancy += RoomCount
            decOccupancyRate = CDec(RoomCount) / 30
            ListBox1.Items.Add(decOccupancyRate * 100)
        Next
        strUserInput = "Total occupancy= " & TotOccupancy.ToString()
        ListBox1.Items.Add(strUserInput)
        decOccupancyRate = CDec(TotOccupancy) / 240
        ListBox1.Items.Add(decOccupancyRate * 100)
Last edited by hhh0505; 22 Days Ago at 11:27 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 42
Reputation: kplcjl is an unknown quantity at this point 
Solved Threads: 5
kplcjl kplcjl is offline Offline
Light Poster
 
0
  #7
22 Days Ago
Hmmm, works for me. 'Course I did say it was from notepad
  1. 'This calculates and displays each floors occupancy rate.
  2. Dim Occupancy(7) As Byte 'Why do you have an array that is going to be dropped
  3. Dim TotOccupancy As Byte = 0 '240 is < 255 - can't overflow
  4. Dim decOccupancyRate As Decimal
  5. Dim strUserInput As String
  6. Dim decOccupancy As Decimal
  7. Dim intCount As Byte
  8. Dim RoomCount As Integer 'User can say 2 billion and shouldn't overflow
  9. 'ListBox1.Items.Add
  10. For intCount = 0 To 7
  11. RoomCount = -1
  12. While RoomCount < 0 Or RoomCount > 30
  13. strUserInput = InputBox("Enter the number of rooms occupied. Provide a value")
  14. If IsNumeric(strUserInput) Then RoomCount = strUserInput
  15. If RoomCount < 0 Or RoomCount > 30 Then
  16. MessageBox.Show("Please enter a number >= 0 and <= 30")
  17. End If
  18. End While
  19. Occupancy(intCount) = RoomCount
  20. TotOccupancy += RoomCount
  21. decOccupancyRate = CDec(RoomCount) / 30.0
  22. ListBox1.Items.Add(decOccupancyRate * 100)
  23. Next
  24. strUserInput = "Total occupancy= " & TotOccupancy.ToString()
  25. ListBox1.Items.Add(strUserInput)
  26. decOccupancyRate = CDec(TotOccupancy) / 240.0
  27. ListBox1.Items.Add(decOccupancyRate * 100)
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 8
Reputation: hhh0505 is an unknown quantity at this point 
Solved Threads: 1
hhh0505 hhh0505 is offline Offline
Newbie Poster
 
0
  #8
22 Days Ago
yea i think im scerwed lo. thanks for the help... still not working
Originally Posted by kplcjl View Post
Hmmm, works for me. 'Course I did say it was from notepad
  1. 'This calculates and displays each floors occupancy rate.
  2. Dim Occupancy(7) As Byte 'Why do you have an array that is going to be dropped
  3. Dim TotOccupancy As Byte = 0 '240 is < 255 - can't overflow
  4. Dim decOccupancyRate As Decimal
  5. Dim strUserInput As String
  6. Dim decOccupancy As Decimal
  7. Dim intCount As Byte
  8. Dim RoomCount As Integer 'User can say 2 billion and shouldn't overflow
  9. 'ListBox1.Items.Add
  10. For intCount = 0 To 7
  11. RoomCount = -1
  12. While RoomCount < 0 Or RoomCount > 30
  13. strUserInput = InputBox("Enter the number of rooms occupied. Provide a value")
  14. If IsNumeric(strUserInput) Then RoomCount = strUserInput
  15. If RoomCount < 0 Or RoomCount > 30 Then
  16. MessageBox.Show("Please enter a number >= 0 and <= 30")
  17. End If
  18. End While
  19. Occupancy(intCount) = RoomCount
  20. TotOccupancy += RoomCount
  21. decOccupancyRate = CDec(RoomCount) / 30.0
  22. ListBox1.Items.Add(decOccupancyRate * 100)
  23. Next
  24. strUserInput = "Total occupancy= " & TotOccupancy.ToString()
  25. ListBox1.Items.Add(strUserInput)
  26. decOccupancyRate = CDec(TotOccupancy) / 240.0
  27. ListBox1.Items.Add(decOccupancyRate * 100)
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 8
Reputation: hhh0505 is an unknown quantity at this point 
Solved Threads: 1
hhh0505 hhh0505 is offline Offline
Newbie Poster

reslly need help

 
0
  #9
21 Days Ago
Basically i have a listbox and the user should be prompetd to enter a value for each floor... 1-8 and you have to give a value for the amount of rooms occupied... then it displays it on the listbox once the loop in complete ...can someoen pelase help me with this code? im really close...
  1. 'This calculates and displays each floors occupancy rate.
  2. Dim intOccupancy(7) As Integer
  3. Dim intTotOccupancy As Integer = 0
  4. Dim decOccupancyRate As Decimal
  5. Dim strUserInput As String
  6. Dim decOccupancy As Decimal
  7. Dim intCount As Byte
  8. Dim intRoomCount As Integer 'User can say 2 billion and shouldn't overflow
  9. 'ListBox1.Items.Add
  10. For intCount = 0 To 7
  11. intRoomCount = -1
  12. While intRoomCount < 0 Or intRoomCount > 30
  13. strUserInput = InputBox("Enter the number of rooms occupied. Provide a value")
  14. If IsNumeric(strUserInput) Then intRoomCount = strUserInput
  15. If intRoomCount < 0 Or intRoomCount > 30 Then
  16. MessageBox.Show("Please enter a number >= 0 and <= 30")
  17. End If
  18. End While
  19. intOccupancy(intCount) = intRoomCount
  20. intTotOccupancy += intRoomCount
  21. decOccupancyRate = CDec(intRoomCount) / 30
  22. ListBox1.Items.Add(decOccupancyRate * 100)
  23. Next
  24. strUserInput = "Total occupancy= " & intTotOccupancy.ToString()
  25. ListBox1.Items.Add(strUserInput)
  26. decOccupancyRate = CDec(CDec(intTotOccupancy) / 240.0)
  27. ListBox1.Items.Add(decOccupancyRate * 100)
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC