diff --git a/respostas-magnolia/desafio/funcao-repeticao/index.html b/respostas-magnolia/desafio/funcao-repeticao/index.html new file mode 100644 index 0000000..aadff42 --- /dev/null +++ b/respostas-magnolia/desafio/funcao-repeticao/index.html @@ -0,0 +1,13 @@ + + + + + + + Desafio Função e Repetição + + +

Desafio - Função e Repetição

+ + + \ No newline at end of file diff --git a/respostas-magnolia/desafio/funcao-repeticao/script.js b/respostas-magnolia/desafio/funcao-repeticao/script.js new file mode 100644 index 0000000..ae7432a --- /dev/null +++ b/respostas-magnolia/desafio/funcao-repeticao/script.js @@ -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() \ No newline at end of file diff --git a/respostas-magnolia/desafio/funcao/index.html b/respostas-magnolia/desafio/funcao/index.html new file mode 100644 index 0000000..f60bba3 --- /dev/null +++ b/respostas-magnolia/desafio/funcao/index.html @@ -0,0 +1,13 @@ + + + + + + + Desafio Função + + +

Desafio - Função

+ + + \ No newline at end of file diff --git a/respostas-magnolia/desafio/funcao/script.js b/respostas-magnolia/desafio/funcao/script.js new file mode 100644 index 0000000..28184c6 --- /dev/null +++ b/respostas-magnolia/desafio/funcao/script.js @@ -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() \ No newline at end of file diff --git a/respostas-magnolia/ex01/index.html b/respostas-magnolia/ex01/index.html new file mode 100644 index 0000000..6b038b3 --- /dev/null +++ b/respostas-magnolia/ex01/index.html @@ -0,0 +1,13 @@ + + + + + + + Exercício 1 + + +

Farmácia JS em Promoção

+ + + \ No newline at end of file diff --git a/respostas-magnolia/ex01/script.js b/respostas-magnolia/ex01/script.js new file mode 100644 index 0000000..2aa7ebb --- /dev/null +++ b/respostas-magnolia/ex01/script.js @@ -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) + } +} \ No newline at end of file diff --git a/respostas-magnolia/ex02/index.html b/respostas-magnolia/ex02/index.html new file mode 100644 index 0000000..50a331a --- /dev/null +++ b/respostas-magnolia/ex02/index.html @@ -0,0 +1,13 @@ + + + + + + + Exercício 2 + + +

Média do Aluno

+ + + \ No newline at end of file diff --git a/respostas-magnolia/ex02/script.js b/respostas-magnolia/ex02/script.js new file mode 100644 index 0000000..2a754d2 --- /dev/null +++ b/respostas-magnolia/ex02/script.js @@ -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() \ No newline at end of file diff --git a/respostas-magnolia/ex03/index.html b/respostas-magnolia/ex03/index.html new file mode 100644 index 0000000..4e97660 --- /dev/null +++ b/respostas-magnolia/ex03/index.html @@ -0,0 +1,13 @@ + + + + + + + Exercício 3 + + +

Desconto Supermercado

+ + + \ No newline at end of file diff --git a/respostas-magnolia/ex03/script.js b/respostas-magnolia/ex03/script.js new file mode 100644 index 0000000..3326a4d --- /dev/null +++ b/respostas-magnolia/ex03/script.js @@ -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() \ No newline at end of file diff --git a/respostas-magnolia/ex04-tabuada/for/index.html b/respostas-magnolia/ex04-tabuada/for/index.html new file mode 100644 index 0000000..34420f9 --- /dev/null +++ b/respostas-magnolia/ex04-tabuada/for/index.html @@ -0,0 +1,13 @@ + + + + + + + Tabuada - For + + +

Tabuada com For

+ + + \ No newline at end of file diff --git a/respostas-magnolia/ex04-tabuada/for/script.js b/respostas-magnolia/ex04-tabuada/for/script.js new file mode 100644 index 0000000..32689c8 --- /dev/null +++ b/respostas-magnolia/ex04-tabuada/for/script.js @@ -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) + "
") + } +} +tabuada() \ No newline at end of file diff --git a/respostas-magnolia/ex04-tabuada/while/index.html b/respostas-magnolia/ex04-tabuada/while/index.html new file mode 100644 index 0000000..69fb74b --- /dev/null +++ b/respostas-magnolia/ex04-tabuada/while/index.html @@ -0,0 +1,13 @@ + + + + + + + Tabuada - While + + +

Tabuada com While

+ + + \ No newline at end of file diff --git a/respostas-magnolia/ex04-tabuada/while/script.js b/respostas-magnolia/ex04-tabuada/while/script.js new file mode 100644 index 0000000..f1450aa --- /dev/null +++ b/respostas-magnolia/ex04-tabuada/while/script.js @@ -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) + "
") + i++ + + } +} +tabuada() \ No newline at end of file