Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Released under the GNU General Public License version 3 by J2897.
- <#
- Go and grab a bottle of bleach, disinfectant or some other concentrated liquid.
- The bottle will tell you to put in "60ml per 5L" or something like that.
- This script will tell you what percentage that is.
- More importantly, it will tell you how much concentrate to put in for the amount you actually need.
- So if the bottle tells you to put in 60ml per 5L, and you only want 2.5L, it will tell you to put in 30ml instead.
- #>
- clear
- # Figure out the percentage.
- [int]$Millilitres = Read-Host -Prompt "How many millilitres of concentrate does the bottle say?"
- [int]$LitresL = Read-Host -Prompt "Per how many litres?"
- [int]$LitresMil = $LitresL * 1000
- [decimal]$Percentage = $Millilitres * 100 / $LitresMil
- Write-Host "The percentage of concentrate is: " -nonewline; Write-Host "$Percentage%" -ForegroundColor Yellow
- Write-Host "`r"
- # Calculate the desired amount.
- [decimal]$SolutionL = Read-Host -Prompt "How many litres do you actually require?"
- [decimal]$SolutionMil = $SolutionL * 1000
- [decimal]$Concentration = $SolutionMil / 100 * $Percentage
- [decimal]$Water = $SolutionMil - $Concentration
- # Construct the results.
- $Results_0 = 'For ' + $SolutionL + 'L mix '
- $Results_1 = "{0:N0}" -f [int]$Water + 'ml'
- $Results_2 = ' of water and '
- $Results_3 = "{0:N0}" -f [int]$Concentration + 'ml'
- $Results_4 = ' of concentrate together.'
- # Display the results.
- Write-Host $Results_0 -nonewline
- Write-Host $Results_1 -nonewline -ForegroundColor Yellow
- Write-Host $Results_2 -nonewline
- Write-Host $Results_3 -nonewline -ForegroundColor Yellow
- Write-Host $Results_4
- Write-Host "`r"
- Write-Host "Press any key to end..."
- [void][System.Console]::ReadKey($true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement