Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions respostas-magnolia/desafio/funcao-repeticao/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!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">
<title>Desafio Função e Repetição</title>
</head>
<body>
<h2>Desafio - Função e Repetição</h2>
<script src="script.js"></script>
</body>
</html>
21 changes: 21 additions & 0 deletions respostas-magnolia/desafio/funcao-repeticao/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
*
* Desafio Função e Repetição:
* Crie um programa que verifique o valor inserido pelo usuário e imprima seus múltiplos (MAX 100 números)
*
**/

function multiplos() {

let numero = Number(prompt('Informe um número'))

for (let i = 1; i <= 100; i++) {

resultado = numero * i

if (resultado <= 100) {
alert(resultado)
}
}
}
multiplos()
13 changes: 13 additions & 0 deletions respostas-magnolia/desafio/funcao/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!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">
<title>Desafio Função</title>
</head>
<body>
<h2>Desafio - Função</h2>
<script src="script.js"></script>
</body>
</html>
32 changes: 32 additions & 0 deletions respostas-magnolia/desafio/funcao/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* Desafio de Função:
* Elabore um programa que leia a velocidade permitida em uma estrada e a velocidade de um condutor.
* Se a velocidade for inferior ou igual a velocidade permitida, exiba a mensagem "Sem Multa".
* Se a velocidade for de até 10% maior que a permitida, exiba "Multa Leve".
* E, se a velocidade for superior a 20% da velocidade permitida, exiba "Multa Grave."
*/

function velocidade() {

let velocidadePermitida = Number(prompt('Informe a velocidade permitida'))
let velocidadeCondutor = Number(prompt('Informe a velocidade do condutor'))
let multa10 = velocidadePermitida + ((velocidadePermitida * 10) / 100)
let multa20 = velocidadePermitida + ((velocidadePermitida * 20) / 100)

if(velocidadeCondutor <= velocidadePermitida) {

alert('Sem Multa!')

} else {

if(velocidadeCondutor >= multa10 && velocidadeCondutor < multa20) {

alert('Multa Leve!')

} else {

alert('Multa Grave!')

}
}
}
velocidade()
13 changes: 13 additions & 0 deletions respostas-magnolia/ex01/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!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">
<title>Exercício 1</title>
</head>
<body>
<h2>Farmácia JS em Promoção</h2>
<script src="script.js"></script>
</body>
</html>
25 changes: 25 additions & 0 deletions respostas-magnolia/ex01/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* Exercício 1:
* Farmacia JS está em promoção.
* A cada 2 produtos iguais comprados, receba 5 reais de desconto.
* Escreva um programa para auxiliar a farmacia a calcular o valor final do produto.
*/

let produto1 = prompt('Informe o nome do produto 1')
let valorProduto1 = Number(prompt('Informe o valor do produto 1: R$'))

let produto2 = prompt('Informe o nome do produto 2')
let valorProduto2 = Number(prompt('Informe o valor do produto 2: R$'))

funcPromocao(produto1, produto2, valorProduto1, valorProduto2)

function funcPromocao(prod1, prod2, valorProd1, valorProd2) {

var totalCompras = valorProd1 + valorProd2

if (prod1 == prod2 && valorProd1 == valorProd2) {
const valorComprasDesconto = totalCompras - 5
return alert("O valor total a pagar (com desconto) é R$ " + valorComprasDesconto)
} else {
return alert("O valor total a pagar é R$ " + totalCompras)
}
}
13 changes: 13 additions & 0 deletions respostas-magnolia/ex02/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!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">
<title>Exercício 2</title>
</head>
<body>
<h2>Média do Aluno</h2>
<script src="script.js"></script>
</body>
</html>
37 changes: 37 additions & 0 deletions respostas-magnolia/ex02/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* Exercício 2:
* Etapa 1 = Elaborar um programa que calcule a média do aluno.
* Etapa 2 = Informar se ele foi aprovado (utilizar estrutura condicional).
* Etapa 3 = GARANTIR que todos os campos serão preenchidos (utilizar return).
*/

// Pegar dados do aluno
function infoAluno() {

let nome = prompt('Digite o nome do aluno')
let nota1 = Number(prompt('Informe a 1ª nota'))
let nota2 = Number(prompt('Informe a 2ª nota'))

// Calcular média do aluno
function calcMediaAluno(n, n1, n2) {

// Antes de calcular a média verificar se os dados foram preenchidos
if(n == '' || n1 == '' || n2 == '') {

alert('Por favor, insira todos os dados.')
return infoAluno()

}

// Calculo da media
const media = (n1 + n2) / 2

// Verifica se o aluno foi aprovado ou reprovado
if(media >= 6) {
return alert(nome + ' a sua média foi ' + media + '. Parabéns, você foi APROVADO!')
} else {
return alert(nome + ' a sua média foi ' + media + '. Você foi REPROVADO!')
}
}
calcMediaAluno(nome, nota1, nota2)
}
infoAluno()
13 changes: 13 additions & 0 deletions respostas-magnolia/ex03/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!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">
<title>Exercício 3</title>
</head>
<body>
<h2>Desconto Supermercado</h2>
<script src="script.js"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions respostas-magnolia/ex03/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* Exercício 3
* Ajude o supermercado a calcular o desconto dos produtos.
* A cada 3 itens comprados, o 4º item sai com 50% de desconto.
*/

function itensComprados() {

let produto = prompt('Informe o nome do produto')
let valorProduto = Number(prompt('Informe o valor do produto'))

let calculo = valorProduto * 3
let promocao = valorProduto / 2
const valorFinal = calculo + promocao

alert("Promoção de: " + produto + ". Leve 4 por: R$ " + valorFinal)

}
itensComprados()
13 changes: 13 additions & 0 deletions respostas-magnolia/ex04-tabuada/for/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!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">
<title>Tabuada - For</title>
</head>
<body>
<h2>Tabuada com For</h2>
<script src="script.js"></script>
</body>
</html>
9 changes: 9 additions & 0 deletions respostas-magnolia/ex04-tabuada/for/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function tabuada() {

var numero = Number(prompt('Informe um número!'))

for (let i = 0; i <= 10; i++) {
document.write(numero + " x " + i + " = " + (numero*i) + "<br>")
}
}
tabuada()
13 changes: 13 additions & 0 deletions respostas-magnolia/ex04-tabuada/while/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!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">
<title>Tabuada - While</title>
</head>
<body>
<h2>Tabuada com While</h2>
<script src="script.js"></script>
</body>
</html>
12 changes: 12 additions & 0 deletions respostas-magnolia/ex04-tabuada/while/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function tabuada() {

var numero = Number(prompt('Informe um número!'))
var i = 0
while (i <= 10){

document.write(numero + " x " + i + " = " + (numero*i) + "<br>")
i++

}
}
tabuada()