Last active
December 16, 2015 07:49
-
-
Save vicentedealencar/5401392 to your computer and use it in GitHub Desktop.
Faça um página que calcula a área de determinadas figuras geométricas, exibindo-a. O programa deverá apresentar um menu com as opções abaixo e deverá permitir que o usuário escolha qualquer uma das opções, quantas vezes desejar até que escolha a opção de fim (5).
1 - quadrado (lado*lado)
2 - retângulo (comprimento * largura)
3 - círculo (3,14 * …
This file contains hidden or 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
var formulas = { | |
q: function () { | |
return Math.pow(~~prompt('lado'), 2); | |
}, | |
r: function () { | |
return ~~prompt('comprimento') * ~~prompt('largura'); | |
}, | |
c: function () { | |
return Math.PI * Math.pow(~~prompt('raio'), 2); | |
}, | |
t: function () { | |
return (~~prompt('base maior') + ~~prompt('base menor')) * ~~prompt('altura') / 2 ; | |
} | |
}; | |
(function go () { | |
alert(formulas[prompt('q, r, c, t?')]()); | |
go(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://jsfiddle.net/gh/gist/library/pure/5401392/