Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Chapter 15 exercises #7 & #11
- ' Name: Hotel Project
- ' Purpose: Display hotel ratings in a bar chart
- ' Programmer: Zachary Hibbard on 2/4/17
- Public Class frmMain
- Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
- Me.Close()
- End Sub
- Private Sub btnCreate_Click(sender As Object, e As EventArgs) Handles btnCreate.Click
- Dim intRating As Integer
- Dim strInputStars As String
- Dim intHotel As Integer
- lblStars.Text = String.Empty
- intHotel = 1
- Do While intHotel <= 5
- strInputStars = InputBox("Rate for hotel " & intHotel & "Enter a number 1 to 6", "Rate Hotel")
- Integer.TryParse(strInputStars, intRating)
- lblStars.Text = lblStars.Text & "Hotel" & ":"
- If intRating < 1 OrElse intRating > 6 Then
- MessageBox.Show("Rating should be between 1 and 6", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
- Else
- For intStars As Integer = 1 To intRating Step 1
- lblStars.Text = lblStars.Text & "*"
- Next intStars
- End If
- lblStars.Text = lblStars.Text & ControlChars.NewLine
- intHotel += 1
- Loop
- End Sub
- End Class
- Public Class frmMain
- Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
- Me.Close()
- End Sub
- Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
- Dim decTotal As Decimal
- Dim decSavings As Decimal
- Decimal.TryParse(txtTotal.Text, decTotal)
- txtSavings.Text = String.Empty
- For intYears As Integer = 10 To 30 Step 10
- txtSavings.Text = txtSavings.Text & "Years: " & intYears & ControlChars.NewLine
- For decRate As Decimal = 0.02 To 0.04 Step 0.01
- decSavings = Financial.Pmt(decRate / 12, intYears * 12, 0, -decTotal)
- txtSavings.Text = txtSavings.Text & " " & decRate.ToString("P0") & "->" & decSavings.ToString("C2") & ControlChars.NewLine
- Next decRate
- txtSavings.Text = txtSavings.Text & ControlChars.NewLine
- Next intYears
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement