Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Program. A theater seating chart is implemented as a table of ticket prices,

ID: 3600242 • Letter: C

Question

C++ Program.

A theater seating chart is implemented as a table of ticket prices, like this

10 10 10 10 10 10 10 10 10 10

10 10 10 10 10 10 10 10 10 10

10 10 10 10 10 10 10 10 10 10

10 10 20 20 20 20 20 20 10 10

10 10 20 20 20 20 20 20 10 10

10 10 20 20 20 20 20 20 10 10

20 20 30 30 30 30 30 30 20 20

20 30 30 40 50 50 40 30 30 20

30 40 50 50 50 50 50 50 40 30

20 40 50 50 50 50 50 50 40 20

The above seating information is saved in a text file. Your program should load the information from the file into an array.

Write a program in C++ that asks users to pick either a seat or a price. When choosing seat, indicate the row and column for the location; when choosing the price, randomly choose a seat with that price; mark the sold seats by changing the price to 0. Make sure your code will check whether the seat is available (doesn’t matter which method you use).

Use loop to determine whether continue to order or not. In each time, the seating chart should be displayed for user. When user stops ordering, your program should output the number of tickets ordered, and amount ordered.

The program used be coded in C++ Language (in Microsoft Visual Studio) and

Objective: Practice reading from a file

Practice using an array.

Explanation / Answer

Option Infer Off

Public Class MainForm
    ' declare class-level variable
    Private points As Integer = 10


    Private Sub exitButton_Click(sender As Object, e As EventArgs) Handles exitButton.Click
        Me.Close()
    End Sub

    Private Sub goalTextBox_KeyPress(sender As Object, e As KeyPressEventArgs) Handles goalTextBox.KeyPress

        ' accept only numbers and the Backspace Key

        If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back Then
            e.Handled = True
        End If
    End Sub

    Private Sub rollButton_Click(sender As Object, e As EventArgs) Handles rollButton.Click
        ' simulates the Lucky Number Game
        Dim randGen As New Random
        Dim random1 As Integer
        Dim random2 As Integer

        'remove images
        firstDiePictureBox.Image = Nothing
        secondDiePictureBox.Image = Nothing

        'disable Roll 'Em button
        rollButton.Enabled = False

        'refresh form and then delay execution
        Me.Refresh()
        System.Threading.Thread.Sleep(1000)

        'generate two random integers from 1 through 6
        random1 = randGen.Next(1, 7)
        random2 = randGen.Next(1, 7)

        'display appropriate image in firstDiePictureBox
        Select Case random1
            Case 1
                firstDiePictureBox.Image = dot1PictureBox.Image
            Case 2
                firstDiePictureBox.Image = dot2PictureBox.Image
            Case 3
                firstDiePictureBox.Image = dot3PictureBox.Image
            Case 4
                firstDiePictureBox.Image = dot4PictureBox.Image
            Case 5
                firstDiePictureBox.Image = dot5PictureBox.Image
            Case Else
                firstDiePictureBox.Image = dot6PictureBox.Image
        End Select

        'display appropriate image in secondDiePictureBox
        Select Case random2
            Case 1
                secondDiePictureBox.Image = dot1PictureBox.Image
            Case 2
                secondDiePictureBox.Image = dot2PictureBox.Image
            Case 3
                secondDiePictureBox.Image = dot3PictureBox.Image
            Case 4
                secondDiePictureBox.Image = dot4PictureBox.Image
            Case 5
                secondDiePictureBox.Image = dot5PictureBox.Image
            Case Else
                secondDiePictureBox.Image = dot6PictureBox.Image
        End Select

        'check sum of random numbers
        If random1 + random2 = 7 Then
            Dim count As Integer = 1
            Do While count <= 10
                numberLabel.Visible = Not numberLabel.Visible
                Me.Refresh()
                System.Threading.Thread.Sleep(200)
                count += 1
            Loop
            points += 2
        Else
            points -= 1
            If points = 0 Then
                MessageBox.Show("Sorry, you lost all of your points!" &
                                "Click the Start Over button to try again.",
                                "Lucky Number Game", MessageBoxButtons.OK,
                                MessageBoxIcon.Information)
            End If
        End If
        ' display points
        pointsLabel.Text = points.ToString
        ' enable Roll ' Em button
        rollButton.Enabled = True

    End Sub

    Private Sub startOverButton_Click(sender As Object, e As EventArgs) Handles startOverButton.Click
        ' start a new game

        points = 10
        pointsLabel.Text = points.ToString
        firstDiePictureBox.Image = Nothing
        secondDiePictureBox.Image = Nothing

    End Sub

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote