解决以下问题 [英] Solve the following problem

查看:102
本文介绍了解决以下问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建一个项目,以跟踪俱乐部的音乐会门票销售情况。门票价格取决于座位位置。使用数组来保存每种座位的价格。



不允许用户收到超出范围的下标异常。



您的计划应计算每个俱乐部会员每个部分的门票总数(至少10名成员)。俱乐部会员的姓名和每个部分的门票数量应该在一个文本文件中(使用下表中显示的顺序。



如果会员做了不销售该部分的任何门票使用0作为条目),程序

应该读取此文本文件,然后创建一个包含该信息的数组(使用拆分方法)。



程序应创建结果的二维数组(原始数组加上售出的总票数和每个成员的总收入(另外2列)显示票价计划。显示列表框中的最后一个数组。最后一行应该有总数。



使用LINQ查询(必须在顶部有选项推断)查找成员前五名销售在摘要表格上显示这个



使用好的编程实践:这样一个合适的启动画面,关于框和菜单。确保你在整个过程中使用评论代码



Typ座位价格每座位价格

乐团40.00

Mezzanine 27.50

一般我15.00

阳台10.00


我尝试了什么:



我尝试以下代码,但问题是通过文本文件和LINQ查询获取数组。如果你读到了问题,你就会得到它。



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.

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

推荐答案

我们不做你的作业:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!



如果遇到具体问题,请询问相关问题,我们会尽力提供帮助。但是我们不会为你做这一切!
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!


Quote:

我尝试以下代码,但问题是通过文本文件和LINQ查询获取数组。如果你读到这个问题,你会得到它。

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.



有什么问题或疑问?



我们不做你的家庭工作。

HomeWork不会测试你乞求别人做你的工作的技能,它会让你思考并帮助你的老师检查你对你所学课程的理解以及你应用它们时遇到的问题。

你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。

你的任何失败都会帮助你了解什么有效,什么无效,被称为'试错'学习。

所以,试一试,重读课程并开始工作。如果您遇到特定问题,请展示您的代码并解释这个问题,我们可能会提供帮助。


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.


这篇关于解决以下问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆