-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhesap-makinesi.php
75 lines (67 loc) · 1.54 KB
/
hesap-makinesi.php
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<html>
<head>
<title>Hesap Makinesi</title>
<style>
input{width: 50px}
select{width: 60px}
.hesap{width: 500px;margin:0 auto;border:1px #dd6600 solid;padding:20px;background:#ccc;}
</style>
</head>
<body>
<div class="hesap">
<form method="post" action="">
Sayı 1: <input type="text" name="sayi1"/>
<select name="islem">
<option value="">İşlem</option>
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
Sayı 2: <input type="text" name="sayi2" />
<button type="submit">Hesapla</button>
</form>
<?php
if($_POST)
{
$sayi1 = intval($_POST['sayi1']);
$sayi2 = intval($_POST['sayi2']);
$islem = $_POST['islem'];
switch($islem) {
case '+':
echo topla($sayi1,$sayi2);
break;
case '-':
echo cikar($sayi1,$sayi2);
break;
case '*':
echo carp($sayi1,$sayi2);
break;
case '/':
echo bol($sayi1,$sayi2);
break;
default:
echo 'Lütfen adam gibi işlem seçin';
break;
}
}
function topla($sayi1,$sayi2)
{
return 'Toplamı: '.($sayi1+$sayi2);
}
function cikar($sayi1,$sayi2)
{
return 'Farkı: '.($sayi1-$sayi2);
}
function carp($sayi1,$sayi2)
{
return 'Çarpımı: '.($sayi1*$sayi2);
}
function bol($sayi1,$sayi2)
{
return 'Böümü '.($sayi1/$sayi2);
}
?>
</div>
</body>
</html>