-
Notifications
You must be signed in to change notification settings - Fork 0
/
UdregningAf2Ligninger.ps1
49 lines (41 loc) · 1.16 KB
/
UdregningAf2Ligninger.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
# UDREGNING AF DISKRIMINANT#
write-Host "Skriv værdien for A"
[single]$A = Read-Host -Prompt 'A'
write-Host "Skriv værdien for B"
[single]$B = Read-Host -Prompt 'B'
write-Host "Skriv værdien for C"
[single]$C = Read-Host -Prompt 'C'
$D = $B*$B-4*$A*$C
clear
write-Host "-------------------"
write-Host "Din ABC værdier er A= $A, B= $B, C= $C"
write-Host "-------------------"
write-Host "Diskriminanten =" $D
write-Host "-------------------"
#UDREGNING AF SQRT#
[single] $r = [math]::Sqrt($D)
write-Host "Kvadratroden er" $r
write-Host "-------------------"
if ( $D -lt 0 ) # HVIS $D LESS THAN 0 = SKRIV
{
write-Host "Der er ingen løsning"
write-Host "-------------------"
}
if ( $D -gt 0 ){.$GTR}
if ( 0 -eq $D ){.$EQ} # HVIS $D EQUAL MED 0 = SKRIV
$GTR = {
write-Host "Der er 2 løsninger"
write-Host "-------------------"
[decimal] $r = [math]::Sqrt($D)
[decimal] $x1 = (-$B+$r)/(2*$A)
[decimal] $x2 = (-$B-$r)/(2*$A)
write-Host "x1 = $x1"
write-Host "x2 = $x2"
}
$EQ = {
write-Host "Der er 1 løsning"
write-Host "-------------------"
[decimal] $x1 = -($B/(2*$A))
write-Host "x1 = $x1"
}
PAUSE