diff --git a/PHP CALC/css/styles.css b/PHP CALC/css/styles.css new file mode 100644 index 0000000..3abc8ce --- /dev/null +++ b/PHP CALC/css/styles.css @@ -0,0 +1,67 @@ +h1{ + font-family: 'Gotham'; + display: flex; + justify-content: center; + align-items: center; +} + +h3{ + font-family: 'Gotham'; +} + +.calculator { + max-width: 300px; + margin: auto; + padding: 20px; + background-color: #ffffff; + border-radius: 8px; + box-shadow: 0 0 40px 20px rgba(0, 0, 0, 0.1); + text-align: center; +} + +.calculator input, + select { + width: 80%; + padding: 10px; + margin-bottom: 10px; + border: 1px solid #cccccc; + border-radius: 4px; + } + +button { + padding: 10px 20px; + background-color: #8a2be2; + color: #ffffff; + border: none; + border-radius: 4px; + cursor: pointer; +} + + button:hover { + background-color: #9932cc; + } + + + +.resultado{ + font-family: 'Gotham'; + font-weight: bold; + display: flex; + justify-content: center; + align-items: center; + max-width: 300px; + margin: auto; + padding: 20px; + background-color: #ffffff; + border-radius: 8px; + box-shadow: 0 0 40px 20px rgba(0, 0, 0, 0.1); + text-align: center; +} + +p{ + font-family: 'Gotham'; + font-weight: bold; + display: flex; + justify-content: center; + align-items: center; +} diff --git a/PHP CALC/index.php b/PHP CALC/index.php new file mode 100644 index 0000000..58515dc --- /dev/null +++ b/PHP CALC/index.php @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<html lang="pt-br"> + +<head> + <meta charset="UTF-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <link rel="stylesheet" href="css/styles.css"> + <title>Calculadora PHP</title> +</head> + +<body> + + <div> + <h1>CALCULDORA</h1> + </div> + + <div class="divc"> + <form class="calculator" action="operacoes.php" method="get"> + <h3>Calculadora Quatro Operações</h3> + <div class="caixatexto"> + <input type="text" id="number1" name="number1" placeholder="Number 1" /> + <input type="text" id="number2" name="number2" placeholder="Number 2" /> + </div> + <select id="operacao" class="select" name="operacao"> + <option> </option> + <option value="Soma">Soma</option> + <option value="Subtracao">Subtracao</option> + <option value="Divisao">Divisao</option> + <option value="Multiplicacao">Multiplicacao</option> + <option value="Raiz">Radiciação</option> + <option value="Potencia">Potênciação</option> + </select> + <button type="submit" class="calcular">Calcular</button> + </form> + </div> +</body> +</html> \ No newline at end of file diff --git a/PHP CALC/operacoes.php b/PHP CALC/operacoes.php new file mode 100644 index 0000000..e41de95 --- /dev/null +++ b/PHP CALC/operacoes.php @@ -0,0 +1,58 @@ +<!DOCTYPE html> +<html lang="pt-br"> + +<head> + <meta charset="UTF-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <link rel="stylesheet" href="css/styles.css"> + <title>Calculadora PHP</title> +</head> + +<body> + + <?php + $operacao = $_GET["operacao"]; + $number1 = $_GET["number1"]; + $number2 = $_GET["number2"]; + $resultado = []; + + switch ($operacao) { + case 'Soma': + $resultado = $number1 + $number2; + break; + case 'Subtracao': + $resultado = $number1 - $number2; + break; + case 'Divisao': + if ($number2 == 0) { + echo "<p>Não é possível dividir por 0.</p>"; + } else { + $resultado = $number1 / $number2; + } + break; + case 'Multiplicacao': + $resultado = $number1 * $number2; + break; + case 'Potencia': + $resultado = $number1 ** $number2; + break; + case 'Raiz': + $resultado = $number1 ** (1 / $number2); + break; + default: + echo "<p>Insira os valores.</p>"; + } + + ?> + + <div class="resultado"> + <p>Resultado: + <?php echo $resultado; ?> + </p> + </div> + <p><a href="index.php">Voltar</a></p> + +</body> + +</html> \ No newline at end of file