PHP Classes

File: Example_english_version.php

Recommend this page to a friend!
  Classes of Serkan Ceylani   Calculator   Example_english_version.php   Download  
File: Example_english_version.php
Role: Example script
Content type: text/plain
Description: Example File (ENGLISH)
Class: Calculator
Perform basic mathematical operations
Author: By
Last change: .
Date: 19 years ago
Size: 1,880 bytes
 

Contents

Class file image Download
<?php
/**
 *@package Examples
 *@author Serkan Ceylani serkan@turk-php.com
 *@copyright 2005 turk-php.com
 */

require_once ("Math.class.php");

// 1+2+3+4+0.5 = 10.50
$add = new Add(new Numbers(array(1,2,3,4,0.5)));
print (
$add->result );

print
"<br>";

// 1-2-3-4-0.5 = -8.50
$substract = new Substract(new Numbers(array(1,2,3,4,0.5)));
print (
$substract->result );

print
"<br>";

// 1*2*3*4*0.5*0.8 = 9.60
$multiply = new Multiply(new Numbers(array(1,2,3,4,0.5,0.8)));
print (
$multiply->result );

print
"<br>";

// 1/2 / 3/4 = 0.04
$divide = new Divide(new Numbers(array(1,2,3,4)));
print (
$divide->result );

print
"<br>";

// 8 % 3 = 2
$modul = new Modul(new Numbers(array(8,3)));
print (
$modul->result );

print
"<br>";

// Factorial:
// No recursion inside the function,"Multiply" object and "range ()" function.
// It just works :)
$faktoryel = new Multiply(new Numbers(range(1,5)));
print (
$faktoryel->result );

print
"<br>";

//Factorial of 7...
$faktoryel = new Multiply(new Numbers(range(1,7)));
print (
$faktoryel->result );

print
"<br>";

// 4 ^ 0.5 = 2
$power = new Power(new Numbers(array(4,0.5)));
print (
$power->result );

print
"<br>";

$circle = new Circle(2.5);

echo
"Circle's chamfer = ".$circle->Chamfer();
print
"<br>";
echo
"Circle's area = ".$circle->Area();
print
"<br>";
echo
"PieArea = ".$circle->PieArea (180);
print
"<br>";
echo
"Arc length = ".$circle->ArcLength(180);


$triangle = new Triangle();
$triangle->setSides(6,8,10);

print
"<br>";
echo
"Angle1 = ".$triangle->findAngle1()." Angle2 = ".$triangle->findAngle2()." Angle3 = ".$triangle->findAngle3();
print
"<br>";
echo
"Area of Triangle :".$triangle->Area();
?>