-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path023 switchcase.html
More file actions
58 lines (43 loc) · 1.33 KB
/
023 switchcase.html
File metadata and controls
58 lines (43 loc) · 1.33 KB
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
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Switch case</title>
<script>
let islem, x,y;
function toplama(a,b){
return a+b;
}
function cikarma(a,b){
return a-b;
}
function bolme(a,b){
if(b!=0)
return a/b;
else return "Sıfıra bölünemez";
}
function carpma(a,b){
return a*b;
}
while(true){
islem=prompt("Aritmetik işlemi giriniz:\n +)Toplam\n -)Çıkarma\n /)Bölme\n *) Çarpma\n X)ÇIKIŞ")
if(islem=="x"|| islem=="X") {
alert("Programdan çıkılıyor...");
break;
} /* While döngüsü çıkışı*/
x=parseFloat(prompt("1. sayıyı giriniz:"));
y=parseFloat(prompt("2. sayıyı giriniz:"));
switch(islem){
case "+": alert(toplama(x,y)); break;
case "-": alert(cikarma(x,y)); break;
case "*": alert(carpma(x,y)); break;
case "/": alert(bolme(x,y)); break;
default: alert("Lütfen *,-,/,+ işaretlerinden birini giriniz"); break;
}
}
</script>
</head>
<body>
</body>
</html>