Check - Circle: Thumb - Up Thumb - Down

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Write a PHP program to create class student with following specification Data members: Name,

Roll Num, Average Marks Member functions: Read and Write Use the above information to read
and write information of two students.

check_circle
Expert Answer

thumb_up
thumb_down
Step 1
/***********************student.php***********************/

<?php
class student
{
public $name;
public $rollNo;
public $avgMarks;

function set_name($name) {
$this->name = $name;
}
function get_name() {
return $this->name;
}

function set_rollNo($rollNo) {
$this->rollNo = $rollNo;
}
function get_rollNo() {
return $this->rollNo;
}

function set_avgMarks($avgMarks) {
$this->avgMarks = $avgMarks;
}
function get_avgMarks() {
return $this->avgMarks;

This study source was downloaded by 100000849659459 from CourseHero.com on 07-07-2022 10:27:02 GMT -05:00

https://www.coursehero.com/file/95397231/Write-a-PHP-program-to-create-class-student-with-following-specification-Data-membersdocx/
}
function read($name,$rollNo,$avgMarks){
$this->set_name($name);
$this->set_rollNo($rollNo);
$this->set_avgMarks($avgMarks);
}
function write(){
echo "<br>";
echo "Student Name : " . $this->get_name();
echo "<br>";
echo "Student Roll Number : " . $this->get_rollNo();
echo "<br>";
echo "Student Average Marks : " . $this->get_avgMarks();
echo "<br>";
}
}

$studentObj1 = new student();


$studentObj1->read('Student1','A1',75.8);
$studentObj1->write();

$studentObj2 = new student();


$studentObj2->read('Student2','A2',82.4);
$studentObj2->write();
?>
/***********************Screenshot***********************/
Step 2

This study source was downloaded by 100000849659459 from CourseHero.com on 07-07-2022 10:27:02 GMT -05:00

https://www.coursehero.com/file/95397231/Write-a-PHP-program-to-create-class-student-with-following-specification-Data-membersdocx/
This study source was downloaded by 100000849659459 from CourseHero.com on 07-07-2022 10:27:02 GMT -05:00

https://www.coursehero.com/file/95397231/Write-a-PHP-program-to-create-class-student-with-following-specification-Data-membersdocx/
Powered by TCPDF (www.tcpdf.org)

You might also like