Given below is a sample application:
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 StadiumSeating
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void calculaterevenueButtonrm_Click(object sender, EventArgs e)
{
try
{
// Declaring for user inputed ticket totals
decimal classatickets;
decimal classbtickets;
decimal classctickets;
classatickets = decimal.Parse(classaTextBoxrm.Text);
classbtickets = decimal.Parse(classbTextBoxrm.Text);
classctickets = decimal.Parse(classcTextBoxrm.Text);
// Storing the cost of each ticket class
decimal classacost = 15;
decimal classbcost = 12;
decimal classccost = 9;
//Declaring names for the results of each class's calculations and how to calculate them
decimal classatotal;
decimal classbtotal;
decimal classctotal;
classatotal = classatickets * classacost;
classbtotal = classbtickets * classbcost;
classctotal = classctickets * classccost;
classarevenueTextBoxrm.Text = classatotal.ToString("c");
classbrevenueTextBoxrm.Text = classbtotal.ToString("c");
classcrevenueTextBoxrm.Text = classctotal.ToString("c");
// Define how to calculate the total sales
decimal totalsales;
totalsales = classatotal + classbtotal + classctotal;
totalrevenueTextBoxrm.Text = totalsales.ToString("c");
}
catch (Exception ex)
{
//default error message
MessageBox.Show(ex.Message);
}
}
private void clearButtonrm_Click(object sender, EventArgs e)
{
classaTextBoxrm.Text = "";
classbTextBoxrm.Text = "";
classcTextBoxrm.Text = "";
classarevenueTextBoxrm.Text = "";
classbrevenueTextBoxrm.Text = "";
classcrevenueTextBoxrm.Text = "";
totalrevenueTextBoxrm.Text = "";
}
private void label11_Click(object sender, EventArgs e)
{
}
}
}
Post A Comment:
0 comments: