Alcohol calculator

Calculate the amount of pure alchohol in litre you consume per year. All forms needs to be filled in.

[void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")
$Form = New-Object 'System.Windows.Forms.Form'
  
$Calculate = {
    
[double]$Result = 0
[double]$beer = $BeerTextBox.Text
[double]$wwine = $WhiteWineTextBox.Text
[double]$rwine = $RedWineTextBox.Text
[double]$spirit = $SpiritTextBox.Text
$result = ($beer*0.5*0.05)+($wwine*0.7*0.08)+($rwine*0.7*0.13)+($spirit*0.7*0.4)
$ResultBox.Text = $Result
}

$Form.Size = "300,300"

$BeerLabel = New-Object 'System.Windows.Forms.Label'
$BeerLabel.Text = "Beer"
$BeerLabel.Location = "10,10"
$BeerLabel.Size = "70,15"
$Form.Controls.add($BeerLabel)

$BeerTextBox = New-Object 'System.Windows.Forms.TextBox'
$BeerTextBox.Location = "80,10"
$BeerTextBox.Text = "~ Antal 50cl 5%"
$Form.Controls.add($BeerTextBox)

$WhiteWineLabel = New-Object 'System.Windows.Forms.Label'
$WhiteWineLabel.Text = "White Wine"
$WhiteWineLabel.Location = "10,25"
$WhiteWineLabel.Size = "70,15"
$Form.Controls.add($WhiteWineLabel)

$WhiteWineTextBox = New-Object 'System.Windows.Forms.TextBox'
$WhiteWineTextBox.Location = "80,25"
$WhiteWineTextBox.Text = "~ Antal 70cl 8%"
$Form.Controls.add($WhiteWineTextBox)

$RedWineLabel = New-Object 'System.Windows.Forms.Label'
$RedWineLabel.Text = "Red Wine"
$RedWineLabel.Location = "10,40"
$RedWineLabel.Size = "70,15"
$Form.Controls.add($RedWineLabel)

$RedWineTextBox = New-Object 'System.Windows.Forms.TextBox'
$RedWineTextBox.Location = "80,40"
$RedWineTextBox.Text = "~ Antal 70cl 13%"
$Form.Controls.add($RedWineTextBox)

$SpiritLabel = New-Object 'System.Windows.Forms.Label'
$SpiritLabel.Text = "Spirit"
$SpiritLabel.Location = "10,55"
$SpiritLabel.Size = "70,15"
$Form.Controls.add($SpiritLabel)

$SpiritTextBox = New-Object 'System.Windows.Forms.TextBox'
$SpiritTextBox.Location = "80,55"
$SpiritTextBox.Text = "~ Antal 70cl 40%"
$Form.Controls.add($SpiritTextBox)

$CalcButton = New-Object 'System.Windows.Forms.Button'
$CalcButton.Location = "10,90"
$CalcButton.Size = "100,40"
$CalcButton.Text = "Calculate"
$CalcButton.add_Click($calculate)
$Form.Controls.add($CalcButton)

$ResultBox = New-Object 'System.Windows.Forms.Label'
$ResultBox.Location = "10,155"
$ResultBox.Size = "100,25"
$ResultBox.Text = "inget ännu"
$Form.Controls.add($ResultBox)

$AverageLabel = New-Object 'System.Windows.Forms.Label'
$AverageLabel.Location = "10,130"
$AverageLabel.Size = "150,25"
$AverageLabel.Text = "Medel i sverige är 10,3"
$Form.Controls.add($AverageLabel)

$Form.showdialog()

Leave a Reply