-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5eb5a6
commit 3aff650
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<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"> | ||
<title>Calculadora</title> | ||
</head> | ||
<body> | ||
|
||
<h1>Calculadora</h1> | ||
<form action=""> | ||
<h3>Forneça uma expressão matemática</h3> | ||
<input type="text" name="expr" size="15"> | ||
|
||
<input type="button" value="Calcular" onclick="calcula(this.form)"> | ||
<input type="reset" value="Limpar"> | ||
|
||
<p>Resultado</p> | ||
<input type="text" name="result" size="15"> | ||
<p id="res">Resultado Final: </p> | ||
</form> | ||
|
||
<script> | ||
function calcula(form){ | ||
if(confirm("Tem certeza?")){ | ||
form.result.value = eval(form.expr.value); | ||
document.getElementById('res').innerHTML = `Resultado Final: ${eval(form.expr.value)}` | ||
}else{ | ||
alert("Tente novamente") | ||
} | ||
} | ||
</script> | ||
|
||
</body> | ||
</html> |