0% found this document useful (0 votes)
72 views2 pages

Practical Slip - 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views2 pages

Practical Slip - 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical Slip – 4

A) Write a C++ program to accept Worker information Worker_Name, No_of_Hours_worked, Pay_Rate and Salary. Write
necessary functions to calculate and display the salary of Worker. (Use default value for Pay_Rate)

#include<iostream> cout << endl << "Worker details" << endl;


using namespace std; cout << "Name: " << Worker_Name << endl;
class WorkerInformation { cout << "Salary: " << calSal(No_Of_Hours_Worked)
char Worker_Name[50]; << endl;
int No_Of_Hours_Worked, Salary; }
public: int calSal(int work_hrs, int pay_rate=100) {
void acccept() { return (work_hrs*pay_rate);
cout << "Enter name of the worker: "; }
cin >> Worker_Name; };
cout << "Enter number of hours worked: "; int main() {
cin >> No_Of_Hours_Worked; WorkerInformation w;
}
void display() { w.acccept();
w.display();
return 0;
}

PHP – A) Define a class Employee having private members — id, name, department, salary. Define parameterized
constructors. Create a subclass called “Manager” with private member bonus. Create 3 objects of the Manager class and
display the details of the manager having the maximum total salary (salary + bonus).

?php $this->bonus=$e; $ob=$ob4->max($ob);


class Employee } $ob5=new
{ public function max($ob) Manager(5,"ramdas","computer",28000,50
private $eid,$ename,$edept, { 00);
$sal; $sal=$this->getdata(); $ob=$ob5->max($ob);
function __construct($a,$b,$c, $total=$sal+$this->bonus; $ob->display();
$d) if($total>self::$total1) ?>
{ {
$this->eid=$a; self::$total1=$total;
$this->ename=$b; return $this;
$this->edept=$c; }
$this->sal=$d; else
} {
public function getdata() return $ob;
{ }
return $this->sal; }
} public function display()
public function display() {
{ parent::display();
echo $this->eid." echo self::$total1;
"; }
echo $this->ename."
"; }
echo $this->edept." $ob=new Manager(0,"ABC","",0,0);
"; $ob1=new
} Manager(1,"ramdas","computer",28000,200
} 0);
class Manager extends $ob=$ob1->max($ob);
Employee $ob2=new
{ Manager(2,"ramdas1","computer",30000,25
private $bonus; 00);
public static $total1=0; $ob=$ob2->max($ob);
function __construct($a,$b,$c, $ob3=new
$d,$e) Manager(3,"ramdas2","computer",32000,30
{ 00);
parent::__construct($a,$b,$c, $ob=$ob3->max($ob);
$d); $ob4=new
Manager(4,"ramdas","computer",28000,400
0);
B. Create an xml file which should comprise the following: Sachin Tendulkar 2000 100 20 Forat least 5 players. Write a
PHPscript to display the details of players who have scored more than 1200 runs and atleast 50 wickets.

slip4-p2-q2.php <cricket>
<?php <player>def</player>
$d=new DOMDocument(); <runs>100</runs>
$d->load("slip4-p1-q2.xml"); <wickets>40</wickets>
<noofnotout>10</noofnotout>
$run=$d->getElementsByTagName('runs'); </cricket>
$wic=$d->getElementsByTagName('wickets');
$name=$d->getElementsByTagName('player'); <cricket>
<player>pqr</player>
foreach($name as $n) <runs>1020</runs>
{ <wickets>60</wickets>
if($run>='12*00' && $wic>='50') <noofnotout>10</noofnotout>
echo "<br>".$n->textContent; </cricket>
else "not";
} <cricket>
?>. <player>xyz</player>
slip4-p1-q2.xml <runs>9000</runs>
<?xml version='1.0' encoding='UTF-8'?> <wickets>90</wickets>
<cricketinfo> <noofnotout>40</noofnotout>
<cricket> </cricket>
<player>abc</player>
<runs>1000</runs> <cricket>
<wickets>50</wickets> <player>lmn</player>
<noofnotout>10</noofnotout> <runs>170</runs>
</cricket> <wickets>80</wickets>
<noofnotout>8</noofnotout>
</cricket>
</cricketinfo>

You might also like