The problem is Dorm and Meal Calculator A university has the following dormitori
ID: 3625062 • Letter: T
Question
The problem is
Dorm and Meal Calculator
A university has the following dormitories:
Allen Hall $1,500 per semester
Pike Hall $1,600 per semester
Farthing Hall $1,200 per semester
University Suites $1,800 per semester
The university also offers the following meal plans:
7 meals per week $560 per semester
14 meals per week $1,095 per semester
Unlimited meals $1,500 per semester
Create an application with two forms. The startup form holds the names of the dormitories and the other holds the meal plans. When the user selects a dormitory and meal plan, the application should show the total charges for the semester on the startup form.
Any code/files you can come up with would be appreciated!
Explanation / Answer
it took me several minutes to figure out your problem. Your code needs some adjustment. In the second form for the btn_Enter click event you declared an integer variable called "Results". So, why don't you do the same for the first form and then add the two variables and assign them to the label text? Here it is for the button in the first form: Public Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click Dim AllenHall As Integer = 1500 Dim PikeHall As Integer = 1600 Dim FathingHall As Integer = 1200 Dim UniversitySuites As Integer = 180 Dim dormResults As Integer If ListBox1.SelectedIndex = -1 Then MessageBox.Show("Select a Meal Plan!") End If If ListBox1.SelectedIndex = 0 Then lblDormCost.Text = AllenHall.ToString dormResults = AllenHall ElseIf ListBox1.SelectedIndex = 1 Then lblDormCost.Text = PikeHall.ToString dormResults = PikeHall ElseIf ListBox1.SelectedIndex = 2 Then lblDormCost.Text = FathingHall.ToString dormResults = FarthingHall ElseIf ListBox1.SelectedIndex = 3 Then lblDormCost.Text = UniversitySuites.ToString dormResults = UniversitySuites End If End Sub And then for btnEnter in the second form add the following code as the last line: Form1.lblDormCost.Text = Form1.dormResults + Results
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.