In: Computer Science
1. Complete Programming Problem #14, Stadium Seating, on page 199 of the textbook. A revised form (original form provided in Figure 3-49) is provided below based upon theAdditional Requirements. Data is also provided to test the application.
The ADDITIONAL REQUIREMENTS described below MUST also be implemented:
This the instructions for my class and I am lost. Here is my code
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 _3333_SilmonD_Lab03
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void calRevButton_Click(object sender, EventArgs
e)
{
double CATickets;
double CBTickets;
double CCTickets;
double totalRevenue;
if (classATicketsTextBox.Text != "" &&
classBTicketsTextBox.Text != "" &&
classCTicketsTextBox.Text != "")
{
CATickets = double.Parse(classATicketsTextBox.Text);
CBTickets = double.Parse(classBTicketsTextBox.Text);
CCTickets = double.Parse(classCTicketsTextBox.Text);
CATickets = CATickets * 15.0;
CBTickets = CBTickets * 12.0;
CCTickets = CCTickets * 9.0;
totalRevenue = CATickets + CBTickets + CCTickets;
classARevenueTextBox.Text = CATickets.ToString("c");
classBRevenueTextBox.Text = CBTickets.ToString("c");
classCRevenueTextBox.Text = CCTickets.ToString("c");
totalRevenueTextBox.Text = totalRevenue.ToString("c");
sumofRevenueTextBox.Text = totalRevenue.ToString("c");
}
}
private void clearButton_Click(object sender, EventArgs e)
{
classATicketsTextBox.Text = "";
classBTicketsTextBox.Text = "";
classCTicketsTextBox.Text = "";
classARevenueTextBox.Text = "";
classBRevenueTextBox.Text = "";
classCRevenueTextBox.Text = "";
totalRevenueTextBox.Text = "";
}
private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}
private void sumofRevenueTextBox_TextChanged(object sender,
EventArgs e)
{
}
private void totalTicketsBox_TextChanged(object sender,
EventArgs e)
{
}
}
}
Visual C # windows application for Stadium seating cost and revenue:
Step1:
Design the form with controls group box, labels, text boxes and buttons as shown below
Step2:
Set the properties of the controls using the below table
Step3:
Source code :
//Source code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace StadiumSeating
{
public partial class Form1 : Form
{
//declare static variables for to accumulate the transactions
count
//total revenue and total tickets
private static int transactions = 0;
private static double toral_revenue = 0;
private static double total_tickets = 0;
public Form1()
{
InitializeComponent();
}
private void calRev_Click(object sender, EventArgs
e)
{
//increment the transactions by 1
transactions = transactions + 1;
//Set constants for class A , class B and class C tickets
cost
const double CLASS_A_COST = 15.0;
const double CLASS_B_COST = 12.0;
const double CLASS_C_COST = 9.0;
//Set A,B and C tickets to 0
int CATickets=0;
int CBTickets = 0;
int CCTickets = 0;
int totalTickets = 0;
//Set revenues of class A,B and C to 0
double classARevenue = 0;
double classBRevenue = 0;
double classCRevenue = 0;
double revenue = 0;
//Use try-catch block for invalid input
try
{
CATickets = int.Parse(classATicketstextBox.Text);
CBTickets = int.Parse(classBTicketstextBox.Text);
CCTickets = int.Parse(classCTicketstextBox.Text);
//Sum class A , class B and class C tickets
totalTickets = CATickets + CBTickets + CCTickets;
//accumulate the total tickets
total_tickets = total_tickets + totalTickets;
totalTicketsLabel.Text = totalTickets.ToString();
//calculate the class A, B and C revnues
classARevenue = CATickets * CLASS_A_COST;
classBRevenue = CBTickets * CLASS_B_COST;
classCRevenue = CCTickets * CLASS_C_COST;
//Set revenues of each class type
classARevenueTextBox.Text = classARevenue.ToString("C2");
classBRevenueTextBox.Text = classBRevenue.ToString("C2");
classCRevenueTextBox.Text =
classCRevenue.ToString("C2");
//set revenue , total revenue
revenue = classARevenue + classBRevenue + classCRevenue;
totalRevenueLabel.Text = revenue.ToString("C2");
//Accumlate total revenue
toral_revenue = toral_revenue + classARevenue + classBRevenue +
classCRevenue;
//Set total revenue, total tickets and
transactions
sumofRevenueLabel.Text = toral_revenue.ToString("C2");
sumofTicketsLabel.Text = total_tickets.ToString("C2");
transactionsLabel.Text = transactions.ToString();
}
//Catch blcok
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
}
/*Double click the clear button and write below code to clear all
the fields the window*/
private void clearButton_Click(object sender, EventArgs e)
{
classATicketstextBox.Text = "";
classBTicketstextBox.Text = "";
classCTicketstextBox.Text = "";
classARevenueTextBox.Text = "";
classBRevenueTextBox.Text = "";
classCRevenueTextBox.Text = "";
totalTicketsLabel.Text = "";
totalRevenueLabel.Text = "";
sumofRevenueLabel.Text = "";
sumofTicketsLabel.Text = "";
transactionsLabel.Text = "";
}
/*Double click the exit button and write below code to
close the window*/
private void exitButton_Click(object sender, EventArgs e)
{
Form1.ActiveForm.Close();
}
}
}
Step4:
Save the application and run , press F5