|
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace BAC_Calc
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.RadioButton radMale;
private System.Windows.Forms.RadioButton radFemale;
private System.Windows.Forms.NumericUpDown valDrinks;
private System.Windows.Forms.NumericUpDown valWeight;
private System.Windows.Forms.NumericUpDown valHours;
private System.Windows.Forms.Label lblBAC;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.lblBAC = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.radMale = new System.Windows.Forms.RadioButton();
this.radFemale = new System.Windows.Forms.RadioButton();
this.valDrinks = new System.Windows.Forms.NumericUpDown();
this.valWeight = new System.Windows.Forms.NumericUpDown();
this.valHours = new System.Windows.Forms.NumericUpDown();
((System.ComponentModel.ISupportInitialize)(this.valDrinks)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.valWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.valHours)).BeginInit();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(100, 16);
this.label1.TabIndex = 0;
this.label1.Text = "Number Of Drinks";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblBAC
//
this.lblBAC.Font = new System.Drawing.Font("Microsoft Sans Serif", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblBAC.Location = new System.Drawing.Point(8, 96);
this.lblBAC.Name = "lblBAC";
this.lblBAC.Size = new System.Drawing.Size(336, 40);
this.lblBAC.TabIndex = 1;
this.lblBAC.Text = "Your BAC Is: ";
this.lblBAC.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.Location = new System.Drawing.Point(240, 16);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(100, 16);
this.label3.TabIndex = 2;
this.label3.Text = "Hours Drinking";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label4
//
this.label4.Location = new System.Drawing.Point(144, 16);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(72, 16);
this.label4.TabIndex = 3;
this.label4.Text = "Weight";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// radMale
//
this.radMale.Location = new System.Drawing.Point(192, 72);
this.radMale.Name = "radMale";
this.radMale.Size = new System.Drawing.Size(64, 24);
this.radMale.TabIndex = 7;
this.radMale.Text = "Male";
//
// radFemale
//
this.radFemale.Location = new System.Drawing.Point(80, 72);
this.radFemale.Name = "radFemale";
this.radFemale.Size = new System.Drawing.Size(88, 24);
this.radFemale.TabIndex = 8;
this.radFemale.Text = "Female";
//
// valDrinks
//
this.valDrinks.Location = new System.Drawing.Point(32, 40);
this.valDrinks.Maximum = new System.Decimal(new int[] {
9999,
0,
0,
0});
this.valDrinks.Name = "valDrinks";
this.valDrinks.Size = new System.Drawing.Size(64, 20);
this.valDrinks.TabIndex = 9;
this.valDrinks.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.valDrinks.ValueChanged += new System.EventHandler(this.calc);
//
// valWeight
//
this.valWeight.Location = new System.Drawing.Point(152, 40);
this.valWeight.Maximum = new System.Decimal(new int[] {
9999,
0,
0,
0});
this.valWeight.Name = "valWeight";
this.valWeight.Size = new System.Drawing.Size(64, 20);
this.valWeight.TabIndex = 10;
this.valWeight.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.valWeight.Value = new System.Decimal(new int[] {
150,
0,
0,
0});
this.valWeight.ValueChanged += new System.EventHandler(this.calc);
//
// valHours
//
this.valHours.Location = new System.Drawing.Point(256, 40);
this.valHours.Maximum = new System.Decimal(new int[] {
9999,
0,
0,
0});
this.valHours.Name = "valHours";
this.valHours.Size = new System.Drawing.Size(64, 20);
this.valHours.TabIndex = 11;
this.valHours.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.valHours.ValueChanged += new System.EventHandler(this.calc);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(352, 141);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.valHours,
this.valWeight,
this.valDrinks,
this.radFemale,
this.radMale,
this.label4,
this.label3,
this.lblBAC,
this.label1});
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(360, 168);
this.MinimumSize = new System.Drawing.Size(360, 168);
this.Name = "Form1";
this.Text = "BAC Calc";
((System.ComponentModel.ISupportInitialize)(this.valDrinks)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.valWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.valHours)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void calc(object sender, System.EventArgs e)
{
double temp = (double)(valDrinks.Value / 2);
if(radFemale.Checked)
{
temp = temp * (7.5 / (double)valWeight.Value);
}
else
{
temp = temp * (double)(9 / valWeight.Value);
}
temp -= (.016 * (double)valHours.Value);
if(temp < 0)
{
temp = 0.00;
}
lblBAC.Text = "Your BAC Is: " + (temp.ToString("0.#####"));
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.