Slip 12 - C) Write PHP Script to create a class account (accno,cust_name). Derive two classes from account as saving_acc(balance, min_amount) and current_acc(balance, min_amount). Display a menu a) Saving Account b) Current Account For each of this display a menu with the following options. 1. Create account 2. Deposit 3. Withdrawal

Solution:

<!DOCTYPE html>

<html>

  <body>

    <form action="slip12.php" method="GET">

      Please select your Account<br />

 

      <input type="checkbox" name="check_b[]" value="saving" />Saving Account<br />

      <input type="checkbox" name="check_b[]" value="current" />Current Account<br />

              <select id="saving">

  <option value="create">Create</option>

  <option value="deposite">Deposit</option>

  <option value="withderw">Withderw</option>

 </select>

    <input type="submit" value="sumbit" />

    </form>

  </body>

</html>

 

 slip12.php


<!DOCTYPE html>

<html>

<body>

 

<?php

class Account {

  public $acc_no;

  public $acc_name;

  public function __construct($acc_name, $acc_no) {

    $this->acc_name = $acc_name;

    $this->acc_no = $acc_no;

  }

  public function intro() {

    echo "The Account name {$this->acc_name} and Account No is {$this->acc_no}.";

  }

}

 

class saveing_acc extends Account {

  public $blance;

  public $min_amount;

  public function __construct($acc_name, $acc_no, $blance,$min_amount) {

    $this->acc_name = $acc_name;


 

    $this->acc_no = $acc_no;

    $this->blance = $blance;

              $this->min_amount = $min_amount;

  }

  public function intro() {

              echo"<table border='2'>";

              echo"<tr><td>Account Name</td><td>Account no</td><td>balance</td><td>min_balance</td></tr>";

             

    echo "<tr><td>{$this->acc_name}</td>";

            echo "<td>{$this->acc_no}</td>"  ;

            echo"<td>{$this->blance}</td>";

            echo"<td>{$this->min_amount}</td></tr>";

           

  }

}

 

class current_acc extends Account {

  public $blan;

  public $min_amt;

  public function __construct($acc_name, $acc_no, $blan,$min_amount) {

    $this->acc_name = $acc_name;

    $this->acc_no = $acc_no;

    $this->blan = $blan;

              $this->min_amount = $min_amount;

  }

  public function intro() {

             

    echo " <tr><td>{$this->acc_name}</td>";

            echo "<td>{$this->acc_no}</td>" ;

            echo "<td>{$this->blan}</td>";

            echo "<td>{$this->min_amount}</td></tr> ";

           

  }

}

echo"</table>";

$saveing_acc= new saveing_acc("Ravindra", 1111, 5000,1000);

$saveing_acc->intro();

$current_acc=new current_acc("Kiran",2222,100000,1000);

$current_acc->intro();

?>

 

</body>

</html>

Post a Comment

0 Comments