Question:
Theater Revenue Programming Challenge in Visual Basic 2012?
2013-09-21 08:41:51 UTC
Looking for code to this problem:

A movie theater only keeps a percentage of the revenue earned from ticket
sales. The remainder goes to the movie company. Create an application that
calculates and displays the following figures for one night's box office
business at a theater:

Gross revenue for adult tickets sold. (Amount of money taken in for all
adult tickets sold)

Net revenue for adult tickets sold. (Amount of money left over after payment
to movie company)

Gross revenue for child tickets sold. (Amount of money taken in for all
child tickets sold)

Net revenue for child tickets sold. (Amount of money left over after payment
to movie company)

Total gross revenue. (Sum of child and adult gross)

Total net revenue. (Sum of child and adult net)

Assume the theater keeps 20% of its box office receipts. Use A named constant in the code to represent this percentage.

This is what I have so far:

Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

' Declare variable for the calculations.

Dim decAdultPrice As Decimal ' Price per adult ticket

Dim decAdultSold As Integer ' Number of adult tickets sold

Dim decTotalGrossAdult As Decimal

Dim decChildPrice As Decimal ' Price per child ticket

Dim decChildSold As Integer

Dim decTotalGrossChild As Decimal ' Number of child tickets sold

Dim decTotalGross As Decimal

Const decREVEUNE As Decimal = CDec(0.2) '

' Adult Calculations

' Declare variables for the calculations.

Dim decAdultPrice = Val(txtAdultTicket.Text)

Dim decAdultSold = Val(txtAdultSold.Text)

Dim decTotalGrossAdult = decAdultPrice * decAdultSold

lblGrossAdult.Text = decTotalGrossAdult.ToString("$ ##.00")

' Child Calculations

decChildPrice = Val(txtChildTicket.Text)

decChildSold = Val(txtChildSold.Text)

decTotalGrossChild = decChildPrice * decChildSold

lblGrossChild.Text = decTotalGrossChild.ToString("$ ##.00")

' Total Calculations

decTotalGross = decTotalGrossAdult + decTotalGrossChild

lblTotalGross.Text = decTotalGross.ToString("$ ##.00")


Dim decTotalNetAdult As Double

Dim decTotalNetChild As Double

Dim decTotalNet As Double

' Adult Net Calculations


decTotalNetAdult = decTotalGrossAdult * decREVEUNE

lblNetAdult.Text = decTotalNetAdult.ToString("$ ##.00")

' Child Net Calculations

decTotalNetChild = decTotalGrossChild * decREVEUNE

lblNetChild.Text = decTotalNeChild.ToString("$ ##.00")

' Total Calclations

decTotalNet = decTotalNetGrossAdult + decTotalNetGrossChild

lblTotalNet.Text = decTotalNet.ToString("$ ##.00")


End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btnClear.Click
' Clear the adult ticket sales.
txtAdultPricePerTicket.Clear()
txtAdultTicketsSold.Clear()

' Clear the child ticket sales.
txtChildPricePerTicket.Clear()
txtChildTicketsSold.Clear()

' Clear the decTotal fields.
lblGrossAdultTicketSales.Text = String.Empty
lblGrossChildTicketSales.Text = String.Empty
lblTotalGrossRevenue.Text = String.Empty
lblNetAdultTicketSales.Text = String.Empty
lblNetChildTicketSales.Text = String.Empty
lblTotalNetRevenue.Text = String.Empty

End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
' Close the form.
Me.Close()
End Sub
End Class
Three answers:
I Don't Eat Vodka
2013-09-21 09:17:09 UTC
There is WAY too much code here for such a simple program. What you basically need is a class of the following format:



Private Members:



const double percentageKept;



Public Members: //



GrossAdult(double totalAdult);

NetAdult(double totalAdult); //this one will be return totalAdult-GrossAdult(totalAdult);

GrossKid(double totalKid);

NetKid(double totalKid); //this one will be return totalKid-GrossKid(totalKid);

GrossTotal(double total);

NetTotal(double total); //this one will be return total-GrossTotal(total);
Funny Or Die
2013-09-21 16:33:42 UTC
Start a Windows application. Enlarge the form. Windows state Maximized.

Drag over two text boxes and label Adult Ticket Sales txtadult

Child Ticket Sales txtchild

drag over a date time picker.

drag over a button name it Calculate or something



It does not talk about setting up a data base. So will skip this.



Double click the button and it should go to your code with private code button click



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim adult, child As Decimal

Dim percent As Decimal

percent = Convert.ToDecimal(Txtpercent.Text)

adult = Convert.ToDecimal(TxtAdult.Text)

child = Convert.ToDecimal(TxtChild.Text)

percent = percent * 0.01



Label4.Text = adult * percent

Label5.Text = child * percent

Label6.Text = (adult * percent) + (child * percent)

Label7.Text = (adult + child)





End Sub
AJ
2013-09-22 03:26:12 UTC
Why are you using a decimal variable? Who's teaching you this?



Best Practice is to use the double variable.



And why are segmenting the type of movie tickets for? based on your code it doesn't matter. oh yeah, I forgot, this is your homework assignment from a textbook that doesn't use common sense in their homework assignments.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Search results for 'Theater Revenue Programming Challenge in Visual Basic 2012?' (Questions and Answers)
666
replies
What are you still waiting to see happen with TV entertainment?
started 2008-09-15 11:27:24 UTC
tvs
Loading...