0% found this document useful (0 votes)
19 views

Control Semana 5 Cristian Catalán Correa Introducción A La Programación Instituto IACC 10-07-2019

The document describes a PHP calculator application that allows users to input two numbers and select an operation (add, subtract, multiply, or divide) to perform on the numbers. The application uses a class called "matematica" that contains methods for each mathematical operation. When the user submits the form, the selected operation is performed on the two numbers and the result is displayed.

Uploaded by

Cristian Catalan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Control Semana 5 Cristian Catalán Correa Introducción A La Programación Instituto IACC 10-07-2019

The document describes a PHP calculator application that allows users to input two numbers and select an operation (add, subtract, multiply, or divide) to perform on the numbers. The application uses a class called "matematica" that contains methods for each mathematical operation. When the user submits the form, the selected operation is performed on the two numbers and the result is displayed.

Uploaded by

Cristian Catalan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Control semana 5

Cristian Catalán Correa

Introducción a la Programación

Instituto IACC

10-07-2019
Desarrollo

<html>

<head>

<title>calculadora control 5</title>

</head>

<body>

<form method="post" action="calculadora.php">

<input type="text" name="num1"><br /><br />

<select name="opciones"><br /><br />

<option value="0">Sumar</option>

<option value="1">Restar</option>

<option value="2">Multiplicar</option>

<option value="3">Dividir</option>

</select>

<input type="text" name="num2"><br /><br />

<input type="submit" name="calcular" value="calcular"><br /><br />


</form>

</body>

</html>

<?php

include("lista.php");

if(isset($_REQUEST['calcular'])){

$x1=$_REQUEST['num1'];

$x2=$_REQUEST['num2'];

$op=$_REQUEST['opciones'];

switch($op){

case 0:echo "$x1 + $x2 = ".matematica::sumar($x1,$x2);

break;

case 1:echo "$x1 - $x2 = ".matematica::restar($x1,$x2);

break;

case 2:echo "$x1 * $x2 = ".matematica::multiplicar($x1,$x2);

break;

case 3:echo "$x1 / $x2 = ".matematica::dividir($x1,$x2);


break;

?>

<?php

class matematica {

public static function sumar($num1,$num2){

$suma=$num1+$num2;

return $suma;

public static function restar($num1,$num2){

$resta=$num1-$num2;

return $resta;
}

public static function multiplicar($num1,$num2){

$multi=$num1*$num2;

return $multi;

public static function dividir($num1,$num2){

$divi=$num1/$num2;

return $divi;

?>

You might also like