-
Notifications
You must be signed in to change notification settings - Fork 0
/
Question3.php
65 lines (47 loc) · 1.66 KB
/
Question3.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
<?php
/* Write a program to determine the cost of an automobile insurance premium, based on driver's age and the
number of accidents that the driver has had. All variables.
o The basic insurance charge is $500. There is a surcharge of $100 if the driver is under 25 and an additional
surcharge for accidents:
# of accidents Accident Surcharge
1 → 25
2 → 25
3 → 75
4 → 75
5 → 100
6 or more → No insurance*/
echo "<br> ========================= LAB 1 QUESTION #3 ============================= " . "<br><br>";
$basicPackage = 500;
$underAge = 100;
$age = 56;
$finalCost = 0;
$accidents = 4;
if($age < 25){
$basicPackage = ($basicPackage + $underAge);
if ($accidents > 0 && $accidents <= 2){
$basicPackage += 25;
echo "Package estimate: " . "$" .$basicPackage . " dollars.";
}elseif ($accidents >= 3 && $accidents <= 4){
$basicPackage += 75;
echo "Package estimate: " . "$" .$basicPackage . " dollars.";
}elseif ($accidents == 5){
$basicPackage += 100;
echo "Package estimate: " . "$" .$basicPackage . " dollars.";
}else{
echo "Im sorry you are not eligible for an insurance premium plan.";
}
}else{
if ($accidents > 0 && $accidents <= 2){
$basicPackage += 25;
echo "Package estimate: " . "$" .$basicPackage . " dollars.";
}elseif ($accidents >= 3 && $accidents <= 4){
$basicPackage += 75;
echo "Package estimate: " . "$" .$basicPackage . " dollars.";
}elseif ($accidents == 5){
$basicPackage += 100;
echo "Package estimate: " . "$" .$basicPackage . " dollars.";
}else{
echo "Im sorry you are not eligible for an insurance premium plan.";
}
}
?>