Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. Chapter 15 exercises #7 & #11
  2.  
  3.  
  4. ' Name: Hotel Project
  5. ' Purpose: Display hotel ratings in a bar chart
  6. ' Programmer: Zachary Hibbard on 2/4/17
  7.  
  8. Public Class frmMain
  9.  
  10. Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
  11. Me.Close()
  12. End Sub
  13.  
  14. Private Sub btnCreate_Click(sender As Object, e As EventArgs) Handles btnCreate.Click
  15. Dim intRating As Integer
  16. Dim strInputStars As String
  17. Dim intHotel As Integer
  18.  
  19. lblStars.Text = String.Empty
  20. intHotel = 1
  21. Do While intHotel <= 5
  22. strInputStars = InputBox("Rate for hotel " & intHotel & "Enter a number 1 to 6", "Rate Hotel")
  23. Integer.TryParse(strInputStars, intRating)
  24. lblStars.Text = lblStars.Text & "Hotel" & ":"
  25. If intRating < 1 OrElse intRating > 6 Then
  26. MessageBox.Show("Rating should be between 1 and 6", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
  27. Else
  28. For intStars As Integer = 1 To intRating Step 1
  29. lblStars.Text = lblStars.Text & "*"
  30. Next intStars
  31. End If
  32.  
  33. lblStars.Text = lblStars.Text & ControlChars.NewLine
  34. intHotel += 1
  35. Loop
  36. End Sub
  37. End Class
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. Public Class frmMain
  46.  
  47. Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
  48. Me.Close()
  49. End Sub
  50.  
  51. Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
  52. Dim decTotal As Decimal
  53. Dim decSavings As Decimal
  54.  
  55. Decimal.TryParse(txtTotal.Text, decTotal)
  56.  
  57. txtSavings.Text = String.Empty
  58.  
  59. For intYears As Integer = 10 To 30 Step 10
  60. txtSavings.Text = txtSavings.Text & "Years: " & intYears & ControlChars.NewLine
  61. For decRate As Decimal = 0.02 To 0.04 Step 0.01
  62. decSavings = Financial.Pmt(decRate / 12, intYears * 12, 0, -decTotal)
  63. txtSavings.Text = txtSavings.Text & " " & decRate.ToString("P0") & "->" & decSavings.ToString("C2") & ControlChars.NewLine
  64. Next decRate
  65. txtSavings.Text = txtSavings.Text & ControlChars.NewLine
  66. Next intYears
  67. End Sub
  68. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement