The River Bend Hotel needs a program that calculates and displays a customer\'s
ID: 3882762 • Letter: T
Question
The River Bend Hotel needs a program that calculates and displays a customer's total bill. Each customer pays a room charge that is based on a per-night rate. For example, if the per-night rate is $55 and the customer stays two nights, the room charge is $110. Customers also may incur a one-time room service charge and one-time telephone charge. In addition, each customer pays an entertainment tax, which is a percentage of the room charge only. Desk-check your solution's algorithm twice, using your own set of data.Explanation / Answer
Option Explicit On
Option Strict On
Option Infer Off
Public Class MainForm
Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
exitButton.Click
Me.Close()
End Sub
Private Sub printButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
printButton.Click
' sends a printout of the interface to the Print preview window
PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
PrintForm1.Print()
End Sub
Private Sub calcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
calcButton.Click
' calculates and displays the room charge, entertainment tax, and total bill
Const PerNightRate As Double = 55
Const TaxRate As Double = 0.1
Dim nights As Integer
Dim roomService As Double
Dim phone As Double
Dim roomChg As Double
Dim tax As Double
Dim total As Double
' assign user input to variables
Integer.TryParse(nightsTextBox.Text, nights)
Double.TryParse(roomServiceTextBox.Text, roomService)
Double.TryParse(phoneTextBox.Text, phone)
' perform calculations
roomChg = nights * PerNightRate
tax = roomChg * TaxRate
total = roomChg + roomService + phone + tax
' display calculated amounts
roomLabel.Text = roomChg.ToString("N2")
taxLabel.Text = tax.ToString("N2")
totalLabel.Text = total.ToString("C2")
nightsTextBox.Focus()
End Sub
End Class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.