My program is not working properly. I input a screenshot of the assignment and my form, the code that I have written is directly under this. Please tell me how to correct it, I am supposed to use checkboxes to purchase the number of tickets that I want and then all of the ticket information is supposed to appear on the other side.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter12: Using Controls
Section: Chapter Questions
Problem 9E
icon
Related questions
Question

My program is not working properly. I input a screenshot of the assignment and my form, the code that I have written is directly under this. Please tell me how to correct it, I am supposed to use checkboxes to purchase the number of tickets that I want and then all of the ticket information is supposed to appear on the other side.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Final
{
public partial class Form1 : Form
{

static int count1 = 0, count2 = 0, count3 = 0, car1Sale = 0, car2Sale = 0, car3Sale = 0;
public Form1()
{
InitializeComponent();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
chkPanel1();
textBox4.Text = Convert.ToString(count1 + count2 + count3);
saleCalulate();

}
private void checkBox14_CheckedChanged(object sender, EventArgs e)
{
chkPanel2();
textBox4.Text = Convert.ToString(count1 + count2 + count3);
saleCalulate();
}
private void button2_Click(object sender, EventArgs e)
{
foreach (Control cBox in this.panel1.Controls)
{
if (cBox is CheckBox)
{
((CheckBox)cBox).Checked = false;
}
}
foreach (Control cBox in this.panel2.Controls)
{
if (cBox is CheckBox)
{
((CheckBox)cBox).Checked = false;
}
}
foreach (Control cBox in this.panel3.Controls)
{
if (cBox is CheckBox)
{
((CheckBox)cBox).Checked = false;
}
}
clearAvailable();
}
private void chkPanel1()
{
clearAvailable();
count1 = 0;
foreach (Control c in this.panel1.Controls)
{
if (c is CheckBox)
{
if (((CheckBox)c).Checked)
{
count1++;
textBox1.Text = count1.ToString();
}
}
}
}
private void clearAvailable()
{
textBox10.Text = "";
textBox11.Text = "";
textBox12.Text = "";
textBox9.Text = "";
}
private void chkPanel2()
{
clearAvailable();
count2 = 0;
foreach (Control c in this.panel2.Controls)
{
if (c is CheckBox)
{
if (((CheckBox)c).Checked)
{
count2++;
textBox2.Text = count2.ToString();
}
}
}
}
private void chkPanel3()
{
clearAvailable();
count3 = 0;
foreach (Control c in this.panel3.Controls)
{
if (c is CheckBox)
{
if (((CheckBox)c).Checked)
{
count3++;
textBox3.Text = count3.ToString();
}
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
chkPanel1();
chkPanel2();
chkPanel3();
textBox4.Text = Convert.ToString(count1 + count2 + count3);
saleCalulate();
}

private void saleCalulate()
{
car1Sale = count1 * 300;
car2Sale = count2 * 200;
car3Sale = count3 * 100;
textBox5.Text = "$" + car1Sale;
textBox6.Text = "$" + car2Sale;
textBox7.Text = "$" + car3Sale;
textBox8.Text = "$" + Convert.ToString(car1Sale + car2Sale + car3Sale);
}
private void checkBox40_CheckedChanged(object sender, EventArgs e)
{
chkPanel3();
textBox4.Text = Convert.ToString(count1 + count2 + count3);
saleCalulate();
}
private void button1_Click(object sender, EventArgs e)
{
textBox9.Text = Convert.ToString(50 - (count1 + count2 + count3));
textBox10.Text = (10 - count1).ToString();
textBox11.Text = (20 - count2).ToString();
textBox12.Text = (20 - count3).ToString();
}
}
}

o! Form1
CAR #1
groupBox2
CAR #3
A
B
Purchase infomation
1
SEATS TO PURCHASE
CAR #1:
CAR #2:
4
CAR #3:
Total seats to purchase: o
CAR #2
SE
PRICE
groupBox3
CAR #1 A D
$300
SEAT SALES:
CAR #1:
CAR #2
$200
2
CAR #2:
CAR #3 A В СD $100
CAR #3:
Total Sales:
5
Purchase
Clear
Seat infomation:
SEATS AVAILABLE/TOTAL:
TOTAL SEATS:
/50
CAR #1:
/10
CAR #2:
/20
CAR #3:
/20
3.
LO
Transcribed Image Text:o! Form1 CAR #1 groupBox2 CAR #3 A B Purchase infomation 1 SEATS TO PURCHASE CAR #1: CAR #2: 4 CAR #3: Total seats to purchase: o CAR #2 SE PRICE groupBox3 CAR #1 A D $300 SEAT SALES: CAR #1: CAR #2 $200 2 CAR #2: CAR #3 A В СD $100 CAR #3: Total Sales: 5 Purchase Clear Seat infomation: SEATS AVAILABLE/TOTAL: TOTAL SEATS: /50 CAR #1: /10 CAR #2: /20 CAR #3: /20 3. LO
Write a program that can be used by MG-Train to purchase tickets. The train has three cars. Car
#1 has 10 seats (rows: 1-5, columns: A and D), Car #2 has 20 seats (rows: 1- 5, columns: A, C,
and D), and Car #3 has 20 seats (rows: 1- 5, columns: A, B, C, and D). Each car has different seat
price (Car #1: $300, Car #2: $200, and Car #3: $100).
The program should display a screen that shows which seats are available and which are taken.
For example, the following screen shows a chart depicting each seat in the train. Seats that are
taken are represented by an M symbol, and seats that are available are represented by a O
symbol.
MG-Train SEAT MAP
Car 1
Purchase Information
Seats to Purchase
Car #1
3.
Car 12
Car 3
3
Total Seats to Purchase:
Car #2
Seat Sales
Car #1:
$300
2
Car 2
$400
3
Car 3:
$300
Total Sales: $1.000
Car 3
Purchase
Clear
AB
C D
Sents Information
Seats (Available / Total)
Total Seats: 24 / 50
SEAT PRICE
Car #1: 9/ 10
Car #2 18 / 20
Car #1
AD: S300
Car 3: 17 / 20
Car N2
ACD: S200
Car #3
ABCD:S100
O DOOD O
O O DO
OO D O D O
KOOO O
Transcribed Image Text:Write a program that can be used by MG-Train to purchase tickets. The train has three cars. Car #1 has 10 seats (rows: 1-5, columns: A and D), Car #2 has 20 seats (rows: 1- 5, columns: A, C, and D), and Car #3 has 20 seats (rows: 1- 5, columns: A, B, C, and D). Each car has different seat price (Car #1: $300, Car #2: $200, and Car #3: $100). The program should display a screen that shows which seats are available and which are taken. For example, the following screen shows a chart depicting each seat in the train. Seats that are taken are represented by an M symbol, and seats that are available are represented by a O symbol. MG-Train SEAT MAP Car 1 Purchase Information Seats to Purchase Car #1 3. Car 12 Car 3 3 Total Seats to Purchase: Car #2 Seat Sales Car #1: $300 2 Car 2 $400 3 Car 3: $300 Total Sales: $1.000 Car 3 Purchase Clear AB C D Sents Information Seats (Available / Total) Total Seats: 24 / 50 SEAT PRICE Car #1: 9/ 10 Car #2 18 / 20 Car #1 AD: S300 Car 3: 17 / 20 Car N2 ACD: S200 Car #3 ABCD:S100 O DOOD O O O DO OO D O D O KOOO O
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 7 steps

Blurred answer
Knowledge Booster
Fundamentals of Testing Strategies
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning