Sunday, December 13, 2015

Area of a Circle Solver in CodeIgniter

A simple program that I wrote that will ask the user to give the radius of the circle and then our program will compute the area of the circle based on the value of the radius provided by the user using CodeIgniter PHP framework.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.
  

Sample Program Output

Program Listing

<?php
error_reporting(0);

class circle extends CI_Controller
{

function index()
{
echo "<html>";
echo "<head>";
echo " <title>Area of a Circle Solver in CodeIgniter </title>";
echo "</head>";
echo "<style>";
echo "body {";
echo "font-family:arial;";
echo "}";
echo "</style>";
echo "<body>";

if(isset($_POST['submit'])){
   $radius = $_POST['radius'];
  
  $pi = 3.14159;
  $area = $pi * $radius * $radius;
  $solve= number_format($area, 2, '.', '');
  $result = "The area of the circle is " .$solve.".";
    
}

if(isset($_POST['clear'])){
   $radius="";
   $result = "";
  }

echo "<form action='' method='post' name='myform' align='center'>";
echo "<h3>Area of a Circle Solver in CodeIgniter </h3>";
echo "<br>";
echo "Give the radius of the circle &nbsp;&nbsp; <input type='text' name='radius' autofocus='true' value=$radius > ";
echo "<br><br>";
echo "<input type='submit' name='submit' value='Compute' ";
echo "title='Click here to find the area of the circle.' />";
echo "&nbsp;&nbsp;&nbsp;";
echo "<input type='submit' name='clear' value='Clear'";
echo "title='Click here to clear the text boxes.' />";
echo "</form>";
echo "<br>";
echo $result;

 }
}
?>


No comments:

Post a Comment