See code below ##If user inputs %100 or a100 or non-numeric value for temp, I need to display "Error: You must enter a numeric Value!" Write-host $("Error: You must enter a numeric Value!") ## then goes back to start ##im guessing if ($value isnot [int]) or something like that for it to work. thank you. ##Error I get without proper coding......What is the temperature in Fahrenheit: a111 ##Cannot convert value "a111" to type "System. Single". Error: "Input string was not in a ##correct format."
Write-Host("="*31)
Write-Host $("Fahrenheit to Celsius Converter")
Write-Host $("Script Written By Jesse ")
Write-Host("="*31)
$value = (Read-Host("What is the temperature in Fahrenheit"))
$fahr = (($value -32) /9) *5
Write-Host $("Fahrenheit", $value, "is equal to Celsius:", [Math]::Round($fahr,3))
$input = (Read-Host("Do you want to convert another Fahrenheit value? (1 = yes, 0 = no)?"))
Write-Host ("="*31)
while ($input)
{
if ($input -eq 1)
{
Write-Host $("Fahrenheit to Celsius Converter")
Write-Host $("Script Written By Jesse Nieto ")
Write-Host ("="*31)
$value = (Read-Host("What is the temperature in Fahrenheit"))
$fahr = (($value -32) /9) *5
Write-Host $("Fahrenheit", $value ,"is equal to Celsius:" ,[Math]::Round($fahr,3))
$input = (Read-Host("Do you want to convert another Fahrenheit value? (1 = yes, 0 = no)?"))
Write-Host("="*31)
}
elseif ($input -eq 0)
{
Write-Host $("Thank You. Bye! ")
break
}
else
{
Write-Host $("Please enter a valid option! ")
$input = (Read-Host ("Do you want to convert another Fahrenheit value? (1 = yes, 0 = no)?"))
Write-Host ("="*31)
}
}