-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfencelenght.php
49 lines (39 loc) · 1.35 KB
/
fencelenght.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
<?php
if (!empty($_POST['setrails']) && !empty($_POST['setposts'])) {
$railing = (int)$_POST['setrails'];
$post = (int)$_POST['setposts'];
}
if (($railing<1) || ($post<2)) {
echo 'Not possible to build a fence, you have not enough material.';
}
if (($railing==1) && ($post==2)) {
echo 'Fence is 1,7 meters long';
echo '<br>';
echo 'You have no railings and posts left';
}
if (($railing==1) && ($post>2)) {
$postleft = ($post - ($railing + 1));
echo 'Fence is 1,7 meters long';
echo '<br>';
echo 'There are ' . $postleft . ' posts, which were not used';
}
if (($railing>=2) && ($post>1) && ($railing == $post)) {
$fence = (($railing-1)*1.5+($post*0.1));
echo 'Fence is '. $fence .' meters long';
echo '<br>';
echo 'One railing was not used';
}
if (($railing>2) && ($post>1) && ($railing > $post)) {
$fence = (($post - 1) * 1.5 + ($post * 0.1));
$railingleft = ($railing - ($post - 1));
echo 'Fence is ' . $fence . ' meters long';
echo '<br>';
echo 'There are ' . $railingleft . ' railings, which were not used';
}
if (($railing>2) && ($post>1) && ($railing < $post)) {
$fence = (($railing * 1.5) + ($railing + 1)* 0.1);
$postleft = ($post - ($railing + 1));
echo 'Fence is ' . $fence . ' meters long';
echo '<br>';
echo 'There are ' . $postleft . ' posts, which were not used';
}