Click here to Skip to main content
15,939,960 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Create a project to keep track of concert ticket sales by your club. Ticket prices are based on the seating location. Use an array to hold the price of each type of seats.

Do not allow the user to receive an exception for subscript out-of-range.

Your program should calculate the total tickets sold for each section for each member of the club (at least 10 members). The club member’s name and the number of tickets sold for each section should be in a text file (Use the order as shown in the table below.

If a member did not sell any tickets for that section use 0 as the entry), The program
should read this text file and then create an array with the information, (Use the Split Method).

The program should create a Two- dimensional array of the results (The original array plus the total tickets sold and total income for each member (2 more columns) Display the Ticket price schedule. Display the final array in a list box. The last line should have the totals.

Use a LINQ query (Must have Option Infer at top) to find the members with the top five Sales Display this on a Summary form

Use Good Programming Practices: Such an appropriate splash screen, an about box, and menus. Make sure that you use comments throughout the code

Type of seating Price per seat
Orchestra 40.00
Mezzanine 27.50
General I 15.00
Balcony 10.00

What I have tried:

I tries the following code but the question says to get the array through text-file and also LINQ query. If you read the question you'll get it.

VB.NET
Public Class MainForm

    Friend PriceDecimal() As Decimal = {40D, 27.5D, 15D, 10D}

    Friend SectionString() As String = {"Orchestra", "Mezzanine", "General", "Balcony"}

    Friend NumberInteger As Integer

    Friend TotalTicketsInteger(3) As Integer

    Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click

        ' Display AboutBox.

        AboutBox1.ShowDialog()

    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click

        ' Close Main Form.

        Me.Close()

    End Sub

    Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearToolStripMenuItem.Click

        ' Clear Main Form for next sale.

        NumberTextBox.Clear()

        'Here Purchase Info control is changed from text box to label

        PurchaseInfoLabel.Text = ""

        AmountDueTextBox.Clear()

        With SelectionListBox

            .SelectedIndex = -1

            .Focus()

        End With

    End Sub

    Private Sub DisplayPricesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisplayPricesToolStripMenuItem.Click

        ' Display Price Schedule. ListBox in Price Schedule Form will display section and price.

        For i = 0 To 3

            PriceScheduleForm.PriceScheduleListBox.Items.Add(SectionString(i) & "     " & PriceDecimal(i).ToString("C"))

        Next

        PriceScheduleForm.ShowDialog()

    End Sub

    Private Sub PrintSummaryToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintSummaryToolStripMenuItem.Click

        ' Begin process for print preview of summary.

        PrintPreviewDialog1.Document = PrintDocument1

        PrintPreviewDialog1.ShowDialog()

    End Sub

    Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

        ' Handle printing and print preview when printing summary.

        Dim PrintFont As New Font("Arial", 12)

        Dim LineHeightSingle As Single = PrintFont.GetHeight + 2

        Dim HorizontalPrintLocationSingle As Single = 250

        Dim VerticalPrintLocationSingle As Single = e.MarginBounds.Top

        Dim ColumnEndSingle As Single

        Dim ColumnXSingle As Single

        Dim FontSizeF As New SizeF

        Dim FormattedOutputString As String

        Dim SalesAmountDecimal(3) As Decimal

        Dim TotalSalesDecimal As Decimal

        ' Print page heading.

        Using HeadingFont As New Font("Arial", 16, FontStyle.Bold)

            e.Graphics.DrawString("Summary of Ticket Sales", HeadingFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)

            ' Blank line between heading and data.

            VerticalPrintLocationSingle += LineHeightSingle * 2

        End Using

       ' Print column headings.

        e.Graphics.DrawString("Section", PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)

        HorizontalPrintLocationSingle += 100

        e.Graphics.DrawString("# Tickets", PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)

        HorizontalPrintLocationSingle += 100

        e.Graphics.DrawString("Ticket Price", PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)

        HorizontalPrintLocationSingle += 100

        e.Graphics.DrawString("Sales Amount", PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)

        HorizontalPrintLocationSingle += 100

        VerticalPrintLocationSingle += LineHeightSingle  

        ' Print data.

        For IndexInteger = 0 To 3

            HorizontalPrintLocationSingle = 250

            ' Section name will be printed in first column

            e.Graphics.DrawString(Me.SelectionListBox.Items(IndexInteger).ToString, PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)

            HorizontalPrintLocationSingle += 100

            ' Each section's # of tickets sold will be right-aligned in 2nd column.

            ' Set ending position for right-aligned column.

            ColumnEndSingle = 400

            ' Format the number.

            FormattedOutputString = TotalTicketsInteger(IndexInteger).ToString

            ' Calculate the X position of the amount.

            ' Measure string in this font.

            FontSizeF = e.Graphics.MeasureString(FormattedOutputString, PrintFont)

            ' Subtract width of string from the column position.

            ColumnXSingle = ColumnEndSingle - FontSizeF.Width

            e.Graphics.DrawString(FormattedOutputString, PrintFont, Brushes.Black, ColumnXSingle, VerticalPrintLocationSingle)

            HorizontalPrintLocationSingle += 100

            e.Graphics.DrawString(FormatCurrency(PriceDecimal(IndexInteger), 2), PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)

            HorizontalPrintLocationSingle += 100

            SalesAmountDecimal(IndexInteger) = TotalTicketsInteger(IndexInteger) * PriceDecimal(IndexInteger)

            TotalSalesDecimal += SalesAmountDecimal(IndexInteger)

            e.Graphics.DrawString(FormatCurrency(SalesAmountDecimal(IndexInteger), 2), PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)

            VerticalPrintLocationSingle += LineHeightSingle

        Next

        HorizontalPrintLocationSingle = 500

        VerticalPrintLocationSingle += LineHeightSingle * 2

        e.Graphics.DrawString("Total Sales: " & FormatCurrency(TotalSalesDecimal, 2), PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)

    End Sub

    Private Sub PurchaseTicketsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PurchaseTicketsToolStripMenuItem.Click

        Dim SelectionString As String

        Dim SelectedPriceDecimal As Decimal

        ' Add number of tickets in current sale to total tickets sold for selected seating section.

        Try

            ' Convert number of tickets purchased to numeric.

            NumberInteger = Integer.Parse(NumberTextBox.Text)

            Try

                SelectionString = SelectionListBox.SelectedItem

                SelectedPriceDecimal = PriceDecimal(SelectionListBox.Items.IndexOf(SelectionString))

                TotalTicketsInteger(SelectionListBox.Items.IndexOf(SelectionString)) += NumberInteger

                PurchaseInfoLabel.Text = "Purchased " & NumberInteger & " ticket(s) at " & FormatCurrency(SelectedPriceDecimal, 2) & " per ticket"

                AmountDueTextBox.Text = FormatCurrency((NumberInteger * SelectedPriceDecimal), 2)

            Catch SectionException As FormatException

                MessageBox.Show("You must first select a seating section.", "Missing Data", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

                SelectionListBox.Focus()

            End Try

        Catch NumberException As FormatException

            MessageBox.Show("Enter desired number of tickets.", "Missing Data", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

            With NumberTextBox

                .Focus()

                .SelectAll()

            End With

        End Try

    End Sub

    Private Sub frmTicketSales_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        For i = 0 To 3

            SelectionListBox.Items.Add(SectionString(i))

        Next

    End Sub

End Class
Posted
Updated 6-May-18 11:34am
v2

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
 
Share this answer
 
Quote:
I tries the following code but the question says to get the array through text-file and also LINQ query. If you read the question you'll get it.

What is the question or problem ?

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900