Files
ASDV-C-Sharp/MP1/StadiumSeating_CalebFontenot/StadiumSeating_CalebFontenot/Form1.cs

80 lines
2.8 KiB
C#
Executable File

using System.CodeDom;
namespace StadiumSeating_CalebFontenot
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// Define constants
public readonly double classASeatsCost = 15;
public readonly double classBSeatsCost = 12;
public readonly double classCSeatsCost = 9;
private void calculateButton_Click(object sender, EventArgs e)
{
// Define Vars
double ticketsSoldNumberA; // Used to store number of tickets sold for Class A
double ticketsSoldNumberB; // Used to store number of tickets sold for Class B
double ticketsSoldNumberC; // Used to store number of tickets sold for Class C
double revenueGeneratedA; //Used to store revenue for Class A
double revenueGeneratedB; //Used to store revenue for Class B
double revenueGeneratedC; //Used to store revenue for Class C
double total;
// Get data
ticketsSoldNumberA = double.Parse(ticketsSoldA.Text);
ticketsSoldNumberB = double.Parse(ticketsSoldB.Text);
ticketsSoldNumberC = double.Parse(ticketsSoldC.Text);
// Calculate!
revenueGeneratedA = ticketsSoldNumberA * classASeatsCost;
revenueGeneratedB = ticketsSoldNumberB * classBSeatsCost;
revenueGeneratedC = ticketsSoldNumberC * classCSeatsCost;
total = revenueGeneratedA + revenueGeneratedB + revenueGeneratedC;
//Output
revenueGeneratedALabel.Text = "$ " + revenueGeneratedA;
revenueGeneratedBLabel.Text = "$ " + revenueGeneratedB;
revenueGeneratedCLabel.Text = "$ " + revenueGeneratedC;
totalLabel.Text = "$ " + total;
}
private void ticketsSoldA_TextChanged(object sender, EventArgs e)
{
clearButton.Enabled = true;
}
private void ticketsSoldB_TextChanged(object sender, EventArgs e)
{
clearButton.Enabled = true;
}
private void ticketsSoldC_TextChanged(object sender, EventArgs e)
{
clearButton.Enabled = true;
}
private void clearButton_Click(object sender, EventArgs e)
{
clearButton.Enabled = false;
revenueGeneratedALabel.Text = "";
revenueGeneratedBLabel.Text = "";
revenueGeneratedCLabel.Text = "";
totalLabel.Text = "";
ticketsSoldA.Text = "";
ticketsSoldB.Text = "";
ticketsSoldC.Text = "";
}
private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}
}
}