-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1e5a95
commit dfb58ff
Showing
2 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/* 1. Write a PHP program to create a class Employee that contains data members as Emp_Name, Dept_name , Basic_sal,DA, HRA,TA , IT,PF,PT , GROSS, DEDUCTION ,NET . It has member functions calculate_gross , calculate_deductions , Calculate_net_salary . Display pay slip of employee. Create and Initialize members Emp_Name, Dept_name , Basic_sal of Employee object by using parameterized constructor. | ||
*/ | ||
|
||
|
||
|
||
class Employee{ | ||
echo $_POST['a']; | ||
public $eid,$Emp_Name,$Dept_name,$Basic_sal,$DA,$HRA,$TA,$IT,$PF,$PT,$GROSS,$DEDUCTION,$NET; | ||
function __construct($Emp_Name,$Dept_name,$Basic_sal,$DA,$HRA,$TA,$IT,$PF,$PT,$GROSS,$DEDUCTION){ | ||
$this->Emp_Name=$Emp_Name; | ||
$this->Dept_name=$Dept_name; | ||
$this->Basic_sal=$Basic_sal; | ||
$this->DA=$DA; | ||
$this->HRA=$HRA; | ||
$this->TA=$TA; | ||
$this->IT=$IT; | ||
$this->PF=$PF; | ||
$this->PT=$PT; | ||
$this->GROSS=$GROSS; | ||
$this->DEDUCTION=$DEDUCTION; | ||
} | ||
public function calculate_gross(){ | ||
//$this->Basic_sal=$Basic_sal; | ||
|
||
$T = $this->Basic_sal+$this->DA+$this->HRA+$this->TA+$this->IT+$this->PF+$this->PT+$this->GROSS+$this->DEDUCTION; | ||
echo " Employee Name : $this->Emp_Name ; Employee Department : $this->Dept_name ;<br> Gross Salary : ".$T; | ||
return $T; | ||
} | ||
public function calculate_deductions(){ | ||
$total_ded = $this->PF+$this->IT+$this->PT; | ||
echo " ; Total Deduction : ".$total_ded; | ||
return $total_ded; | ||
|
||
} | ||
public function Calculate_net_salary(){ | ||
$a=$this->calculate_gross(); | ||
$b=$this->calculate_deductions(); | ||
$net_salary = $a+$b; | ||
echo "<br> Net Salary : ".$net_salary; | ||
|
||
} | ||
} | ||
|
||
|
||
$ob=new Employee("Nagesh","BCA Science",233333,2222,34,33,33,444,44,88,99,99); | ||
// echo $ob->Emp_Name; | ||
// $ob->calculate_gross(); | ||
// $ob->calculate_deductions(); | ||
$ob->Calculate_net_salary(); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
/* 1. Write a PHP program to create a class article having articleid, name, articleqty, price. Write menu driven program to perform following functions :( Use array of objects) i. Display details of all articles purchased. ii. Display details of articles whose price exceeds 500 iii. Display details of articles whose quantity exceeds 50 | ||
*/ | ||
?> | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>menu driven program</title> | ||
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> --> | ||
</head> | ||
<body> | ||
<form method="post" action="<?php echo($_SERVER['PHP_SELF']); ?> "> | ||
<h1><p style="font-size: 30px; color: red" >Please Select Option To Perform Following Action :</p> </h1> | ||
<h3><input type="radio" name="a" value="a"> i. Display details of all articles purchased.<br> | ||
</h3><h3><input type="radio" name="a" value="b"> ii. Display details of articles whose price exceeds 500 <br> | ||
</h3><h3><input type="radio" name="a" value="c">iii. Display details of articles whose quantity exceeds 50<br> | ||
<input type="submit" name="submit" value="submit"> | ||
</form> | ||
</body> | ||
</html> | ||
|
||
<?php | ||
class Article{ | ||
public $aid,$a_name,$quantity,$price; | ||
|
||
function __construct($aid,$a_name,$quantity,$price){ | ||
$this->aid=$aid; | ||
$this->a_name=$a_name; | ||
$this->quantity=$quantity; | ||
$this->price=$price; | ||
// echo $_POST['a']; | ||
|
||
} | ||
public function details_of_Articles($a){ | ||
foreach ($a as $key => $value) { | ||
echo "<br><p style = font-size:20; > Details of Articles are :<br><p>";//print_r($a[$key]);echo "<br>"; | ||
echo " article no : $value->aid ; Article Name : $value->a_name ;<br> Article Quantity : $value->quantity ;<br> Article Price : $value->price"; | ||
} | ||
} | ||
public function price_exceeds_500($a){ | ||
foreach ($a as $key => $value) { | ||
if($value->price > 500){ | ||
echo "<br><p style = font-size:20; > Price Exceeds 500 is :<br><p>";//print_r($a[$key]);echo "<br>"; | ||
echo " article no : $value->aid ; Article Name : $value->a_name ;<br> Article Quantity : $value->quantity ;<br> Article Price : $value->price"; | ||
} | ||
} | ||
} | ||
public function quantity_exceeds_50($a){ | ||
foreach ($a as $key => $value) { | ||
if($value->quantity > 50){ echo "$value->quantity"; | ||
//print_r($a[$key]); | ||
echo "<br><p style = font-size:20; > Quantity Exceeds 50 is :<br><p>"; | ||
echo " article no : $value->aid ; Article Name : $value->a_name ;<br> Article Quantity : $value->quantity ;<br> Article Price : $value->price"; | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
if (isset($_POST['a'])){ | ||
$choice = $_POST['a']; | ||
$ob=new Article(1,"Nagesh",8,900); | ||
$ob1=new Article(1,"XYZ",58,800); | ||
$a=[$ob,$ob1]; | ||
//print_r($a); | ||
|
||
switch ($choice) { | ||
case 'a': | ||
$ob->details_of_Articles($a); | ||
break; | ||
case 'b': | ||
$ob->price_exceeds_500($a); | ||
break; | ||
|
||
case 'c': | ||
$ob->quantity_exceeds_50($a); | ||
break; | ||
} | ||
// $ob->calculate_gross(); | ||
// $ob->calculate_deductions(); | ||
|
||
|
||
} | ||
?> |