-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBack-To-School-Challenge.ps1
49 lines (45 loc) · 1.5 KB
/
Back-To-School-Challenge.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#challenge link https://ironscripter.us/powershell-back-to-school-scripting-challenge/
function Measure-Hypotenuse {
Write-Output "Please give the 2 values of a right triangles legs."
1..2 | % { sv $_ (read-host) }; "The hypotenuse of this right triangle is $("{0:N3}"-f[math]::sqrt($1/1*$1+$2/1*$2))"
}
function Get-CircleArea {
Write-Output "Please give the value of the diameter."
$diameter = read-host
$radius = $diameter / 2
$radiusSquared = $radius * $radius
$pi = [Math]::PI
$area = $pi * $radiusSquared
Write-Output "The area of this circle is $area"
}
function Get-SphereVolume {
Write-Output "Please give the value of the diameter."
$diameter = read-host
$radius = $diameter / 2
$pi = [Math]::PI
$radiusPow = [Math]::Pow($radius,3)
$volume = (4/3) * ($pi * $radiusPow)
Write-Output "The volume of this sphere is $volume"
}
function Get-CylinderVolume {
Write-Output "Please give the value of the diameter."
$diameter = Read-Host
Write-Output "Please give the value of the height."
$height = Read-Host
$pi = [Math]::PI
$radius = $diameter / 2
$radiusSquared = $radius * $radius
$volume = $pi * $radiusSquared * $height
Write-Output " The volume of this cylinder is $volume"
}
function Get-Factorial {
Write-Output "Please give a number"
$int = read-host
if ($int -eq 0) {
return 1
} else {
$product = 1
1..$int | ForEach-Object { $product *= $_ }
return $product
}
}