Advertisement
J2897

Disinfectant Calculator

Jun 20th, 2016
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Released under the GNU General Public License version 3 by J2897.
  2.  
  3. <#
  4.     Go and grab a bottle of bleach, disinfectant or some other concentrated liquid.
  5.     The bottle will tell you to put in "60ml per 5L" or something like that.
  6.     This script will tell you what percentage that is.
  7.     More importantly, it will tell you how much concentrate to put in for the amount you actually need.
  8.     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.
  9. #>
  10.  
  11. clear
  12.  
  13. # Figure out the percentage.
  14. [int]$Millilitres = Read-Host -Prompt "How many millilitres of concentrate does the bottle say?"
  15. [int]$LitresL = Read-Host -Prompt "Per how many litres?"
  16. [int]$LitresMil = $LitresL * 1000
  17. [decimal]$Percentage = $Millilitres * 100 / $LitresMil
  18. Write-Host "The percentage of concentrate is: " -nonewline; Write-Host "$Percentage%" -ForegroundColor Yellow
  19. Write-Host "`r"
  20.  
  21. # Calculate the desired amount.
  22. [decimal]$SolutionL = Read-Host -Prompt "How many litres do you actually require?"
  23. [decimal]$SolutionMil = $SolutionL * 1000
  24. [decimal]$Concentration = $SolutionMil / 100 * $Percentage
  25. [decimal]$Water = $SolutionMil - $Concentration
  26.  
  27. # Construct the results.
  28. $Results_0 = 'For ' + $SolutionL + 'L mix '
  29. $Results_1 = "{0:N0}" -f [int]$Water + 'ml'
  30. $Results_2 = ' of water and '
  31. $Results_3 = "{0:N0}" -f [int]$Concentration + 'ml'
  32. $Results_4 = ' of concentrate together.'
  33.  
  34. # Display the results.
  35. Write-Host $Results_0 -nonewline
  36. Write-Host $Results_1 -nonewline -ForegroundColor Yellow
  37. Write-Host $Results_2 -nonewline
  38. Write-Host $Results_3 -nonewline -ForegroundColor Yellow
  39. Write-Host $Results_4
  40. Write-Host "`r"
  41.  
  42. Write-Host "Press any key to end..."
  43. [void][System.Console]::ReadKey($true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement