ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Quadratic.php
Go to the documentation of this file.
1 <html>
2 <head>
3 <title>Quadratic Equation Solver</title>
4 </head>
5 <body>
6 <?php
7 
9 error_reporting(E_ALL);
10 
12 set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../Classes/');
13 
14 ?>
15 <h1>Quadratic Equation Solver</h1>
16 <form action="Quadratic.php" method="POST">
17 Enter the coefficients for the Ax<sup>2</sup> + Bx + C = 0
18 <table border="0" cellpadding="0" cellspacing="0">
19  <tr><td><b>A&nbsp;</b></td>
20  <td><input name="A" type="text" size="8" value="<?php echo (isset($_POST['A'])) ? htmlentities($_POST['A']) : ''; ?>"></td>
21  </tr>
22  <tr><td><b>B&nbsp;</b></td>
23  <td><input name="B" type="text" size="8" value="<?php echo (isset($_POST['B'])) ? htmlentities($_POST['B']) : ''; ?>"></td>
24  </tr>
25  <tr><td><b>C&nbsp;</b></td>
26  <td><input name="C" type="text" size="8" value="<?php echo (isset($_POST['C'])) ? htmlentities($_POST['C']) : ''; ?>"></td>
27  </tr>
28 </table>
29 <input name="submit" type="submit" value="calculate"><br />
30 If A=0, the equation is not quadratic.
31 </form>
32 
33 <?php
35 if (isset($_POST['submit'])) {
36  if ($_POST['A'] == 0) {
37  echo 'The equation is not quadratic';
38  } else {
40  include 'PHPExcel/IOFactory.php';
41 
43  $objPHPExcel = PHPExcel_IOFactory::load('./Quadratic.xlsx');
44 
46  $objPHPExcel->getActiveSheet()->setCellValue('A1', $_POST['A']);
47  $objPHPExcel->getActiveSheet()->setCellValue('B1', $_POST['B']);
48  $objPHPExcel->getActiveSheet()->setCellValue('C1', $_POST['C']);
49 
50 
52  echo '<hr /><b>Roots:</b><br />';
53 
54  $callStartTime = microtime(true);
55  echo $objPHPExcel->getActiveSheet()->getCell('B5')->getCalculatedValue().'<br />';
56  echo $objPHPExcel->getActiveSheet()->getCell('B6')->getCalculatedValue().'<br />';
57  $callEndTime = microtime(true);
59 
60  echo '<hr />Call time for Quadratic Equation Solution was '.sprintf('%.4f',$callTime).' seconds<br /><hr />';
61  echo ' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB<br />';
62  }
63 }
64 
65 ?>
66 
67 </body>
68 <html>
Sum of both Ranges is
Definition: 03formulas.php:77
$objPHPExcel
< span style="color:black;"> TC</span >< span style="color:white;"> PDF</span > & nbsp
Definition: example_001.php:88
static load($pFilename)
Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution.
Definition: IOFactory.php:190
$callStartTime
html()
$callTime
$_POST["username"]
$callEndTime
Set page orientation and size
Definition: 04printing.php:77