├── CaixaEletronico ├── app.js ├── index.html └── style.css ├── ConsultorioOdontologico ├── app.js ├── index.html └── style.css ├── ContasDoMes ├── app.js ├── index.html └── style.css ├── CriacaoDeChinchilas ├── app.js ├── index.html └── style.css ├── DescubraONumero ├── app.js ├── index.html └── style.css ├── FabricaDeEstrelas ├── app.js ├── index.html └── style.css ├── FabricaDeEstrelas2 ├── app.js ├── index.html └── style.css ├── Farmacia ├── app.js ├── index.html └── style.css ├── FusoHorario ├── app.js ├── index.html └── style.css ├── JogosEliminatorios ├── app.js ├── index.html └── style.css ├── LadosDoTriangulo ├── app.js ├── index.html └── style.css ├── LanHouse ├── app.js ├── index.html └── style.css ├── Locadora ├── app.js ├── index.html └── style.css ├── MediaDoAluno ├── app.js ├── index.html └── style.css ├── NumerosDecrescentes ├── app.js ├── index.html └── style.css ├── NumerosEmOrdem ├── app.js ├── index.html └── style.css ├── NumerosPerfeitos ├── app.js ├── index.html └── style.css ├── NumerosPrimos ├── app.js ├── index.html └── style.css ├── ParOuImpar ├── app.js ├── index.html └── style.css ├── Parquimetro ├── app.js ├── index.html └── style.css ├── PesoIdeal ├── app.js ├── index.html └── style.css ├── ProgramaBrinquedoteca ├── app.js ├── index.html └── style.css ├── ProgramaConcurso ├── app.js ├── index.html └── style.css ├── README.md ├── RaizQuadrada ├── app.js ├── index.html └── style.css ├── RepeteFruta ├── app.js ├── index.html └── style.css ├── Restaurante ├── app.js ├── index.html └── style.css ├── RevendaDeVeiculos ├── app.js ├── index.html └── style.css ├── RevendaHerbie ├── app.js ├── index.html └── style.css ├── Supermercado ├── app.js ├── index.html └── style.css ├── Tabuada ├── app.js ├── index.html └── style.css ├── UltimasNoticias ├── app.js ├── index.html └── style.css ├── VerificaVelocidade ├── app.js ├── index.html └── style.css └── questoes.md /CaixaEletronico/app.js: -------------------------------------------------------------------------------- 1 | const inputValorDoSaque = document.getElementById('inputValorDoSaque'); 2 | const btnSaque = document.getElementById('btnSaque'); 3 | const outNotasDe100 = document.getElementById('outNotasDe100'); 4 | const outNotasDe50 = document.getElementById('outNotasDe50'); 5 | const outNotasDe10 = document.getElementById('outNotasDe10'); 6 | 7 | function calcularSaque() { 8 | 9 | let valorDoSaque = Number(inputValorDoSaque.value); 10 | 11 | // calcula a quantidade de cada nota 12 | let numeroDeNotas100 = Math.floor(valorDoSaque / 100); 13 | let restanteDe100 = valorDoSaque % 100; 14 | let numeroDeNotas50 = Math.floor(restanteDe100 / 50); 15 | let restanteDe50 = restanteDe100 % 50; 16 | let numeroDeNotas10 = Math.floor(restanteDe50 / 10); 17 | 18 | if ((inputValorDoSaque.value == 0 || inputValorDoSaque == '') || isNaN(valorDoSaque)) { // valida o valor do input 19 | alert('Digite o valor á sacar !'); 20 | inputValorDoSaque.focus(); 21 | return; 22 | } else if (valorDoSaque % 10 !== 0) { // verifica se é multiplo de 10 23 | alert('Esse caixa só possue notas de R$10, R$50 e R$100 !'); 24 | inputValorDoSaque.value = ''; 25 | inputValorDoSaque.focus(); 26 | return; 27 | 28 | } else { // retorna a quantidade de notas 29 | outNotasDe100.textContent = `Notas de R$100: ${numeroDeNotas100}`; 30 | outNotasDe50.textContent = `Notas de R$50: ${numeroDeNotas50}`; 31 | outNotasDe10.textContent = `Notas de R$10: ${numeroDeNotas10}`; 32 | } 33 | /* 34 | if (numeroDeNotas100 > 0) { 35 | outNotasDe100.textContent = `Notas de R$100: ${numeroDeNotas100}`; 36 | } 37 | 38 | if (numeroDeNotas50 > 0) { 39 | outNotasDe50.textContent = `Notas de R$50: ${numeroDeNotas50}`; 40 | } 41 | 42 | if (numeroDeNotas10 > 0) { 43 | outNotasDe10.textContent = `Notas de R$10: ${numeroDeNotas10}`; 44 | } 45 | */ 46 | } 47 | 48 | btnSaque.addEventListener('click', calcularSaque); -------------------------------------------------------------------------------- /CaixaEletronico/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Caixa Eletrônico 9 | 10 | 11 |
12 |

Caixa Eletrônico

13 |
14 | 15 | 16 |
17 | 18 |
19 |

20 |

21 |

22 |
23 |
24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /CaixaEletronico/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | margin: 20px; 22 | border-bottom: 1px solid black; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | padding: 5px; 32 | width: 12.7em; 33 | margin: 10px; 34 | } 35 | 36 | p { 37 | padding: 5px 0; 38 | } -------------------------------------------------------------------------------- /ConsultorioOdontologico/app.js: -------------------------------------------------------------------------------- 1 | const inputPaciente = document.getElementById('inputPaciente'); 2 | const btnConsulta = document.getElementById('btnConsulta'); 3 | const btnUrgencia = document.getElementById('btnUrgencia'); 4 | const btnAtender = document.getElementById('btnAtender'); 5 | const pacienteEmAtendimento = document.getElementById('pacienteEmAtendimento'); 6 | const outConsulta = document.getElementById('outConsulta'); 7 | 8 | let todosPacientes = []; 9 | 10 | function marcarConsulta() { 11 | 12 | let nomePaciente = inputPaciente.value; 13 | 14 | if (nomePaciente == '') { 15 | alert('Digite seu nome !'); 16 | inputPaciente.focus(); 17 | return; 18 | } 19 | 20 | todosPacientes.push(nomePaciente); 21 | let lista = ''; 22 | 23 | for (let index = 0; index < todosPacientes.length; index++) { 24 | lista += `${(index + 1)}. ${todosPacientes[index]}\n`; 25 | 26 | } 27 | 28 | outConsulta.textContent = lista; 29 | inputPaciente.value = ''; 30 | inputPaciente.focus(); 31 | 32 | } 33 | 34 | btnConsulta.addEventListener('click', marcarConsulta); 35 | 36 | function atendimentoPrioritario() { 37 | 38 | let nomePaciente = inputPaciente.value; 39 | 40 | if (nomePaciente == '') { 41 | alert('Digite seu nome !'); 42 | inputPaciente.focus(); 43 | return; 44 | } 45 | 46 | todosPacientes.unshift(nomePaciente); 47 | let lista = ''; 48 | 49 | for (let index = 0; index < todosPacientes.length; index++) { 50 | 51 | lista += `${(index + 1)}. ${todosPacientes[index]}\n`; 52 | 53 | } 54 | outConsulta.textContent = lista; 55 | inputPaciente.value = ''; 56 | inputPaciente.focus(); 57 | 58 | } 59 | 60 | btnUrgencia.addEventListener('click', atendimentoPrioritario); 61 | 62 | function atenderPaciente() { 63 | 64 | if (todosPacientes.length == 0) { 65 | alert('Não há pacientes para atender !'); 66 | inputPaciente.focus(); 67 | return; 68 | } 69 | 70 | let atender = todosPacientes.shift(); 71 | pacienteEmAtendimento.textContent = atender; 72 | let lista = ''; 73 | 74 | for (let index = 0; index < todosPacientes.length; index++) { 75 | lista += `${(index + 1)}. ${todosPacientes[index]}\n`; 76 | 77 | } 78 | 79 | outConsulta.textContent = lista; 80 | } 81 | 82 | btnAtender.addEventListener('click', atenderPaciente); 83 | -------------------------------------------------------------------------------- /ConsultorioOdontologico/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Consutório Odontológico 9 | 10 | 11 |
12 |

Consutório Odontológico

13 |
14 | 15 | 16 |
17 |
18 | 19 | 20 | 21 |
22 |
23 |

Em Atendeimento:

24 |
25 |
26 |

27 |         
28 |
29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /ConsultorioOdontologico/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | } 18 | 19 | h1 { 20 | margin: 10px; 21 | border-bottom: 1px solid black; 22 | } 23 | 24 | label { 25 | display: block; 26 | padding: 5px 0; 27 | } 28 | 29 | input[type="button"] { 30 | padding: 5px; 31 | margin: 10px 0; 32 | } 33 | 34 | h3 { 35 | margin: 10px; 36 | } 37 | -------------------------------------------------------------------------------- /ContasDoMes/app.js: -------------------------------------------------------------------------------- 1 | const inputDescricao = document.getElementById('inputDescricao'); 2 | const inputValorAPagar = document.getElementById('inputValorAPagar'); 3 | const btnPagar = document.getElementById('btnPagar'); 4 | const outContas = document.getElementById('outContas'); 5 | const outTotal = document.getElementById('outTotal'); 6 | 7 | // Variáveis globais que contam e somam respectivamente os valores do inputs 8 | let numeroDeContas = 0; 9 | let valorTotal = 0; 10 | 11 | // varirável que acumula as contas "as linhas" 12 | let quantidade = ''; 13 | 14 | function registrarContas() { 15 | 16 | let descricao = inputDescricao.value; 17 | let valorAPagar = Number(inputValorAPagar.value); 18 | 19 | // condicianal que checa se tem algum erro com os inputs 20 | if (descricao == '' || valorAPagar == 0 || isNaN(valorAPagar)) { 21 | alert('Informe os dados corretamente...'); 22 | inputDescricao.value = ''; 23 | inputValorAPagar.value = ''; 24 | inputDescricao.focus(); 25 | return; 26 | } 27 | 28 | // adiciona os valores dos inputs as variáveis globais 29 | numeroDeContas++; 30 | valorTotal += valorAPagar; 31 | 32 | // adiciona as linhas com as contas 33 | quantidade += `${descricao} - R$: ${(valorAPagar).toFixed(2)}\n`; 34 | // altera o conteúdo nos outputs 35 | outContas.textContent = `${quantidade}----------------------`; 36 | outTotal.textContent = `${numeroDeContas} Conta(s) - Total R$: ${(valorTotal).toFixed(2)}`; 37 | 38 | // Limpa os inputs 39 | inputDescricao.value = ''; 40 | inputValorAPagar.value = ''; 41 | inputDescricao.focus(); 42 | } 43 | 44 | btnPagar.addEventListener('click', registrarContas); -------------------------------------------------------------------------------- /ContasDoMes/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Contas do Mês 9 | 10 | 11 |
12 |

Contas do Mês

13 |
14 | 15 | 16 |
17 |
18 | 19 | 20 |
21 | 22 |
23 |

24 |             

25 |         
26 |
27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /ContasDoMes/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | border-bottom: 1px solid black; 22 | margin: 20px; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | padding: 5px; 32 | margin: 10px; 33 | width: 12.7em; 34 | } 35 | -------------------------------------------------------------------------------- /CriacaoDeChinchilas/app.js: -------------------------------------------------------------------------------- 1 | const inputChinchilas = document.getElementById('inputChinchilas'); 2 | const inputAno = document.getElementById('inputAno'); 3 | const btnChinchilas = document.getElementById('btnChinchilas'); 4 | const outChinchilas = document.getElementById('outChinchilas'); 5 | 6 | 7 | 8 | function mostarPrevisao() { 9 | 10 | let numeroChinchilas = Number(inputChinchilas.value); 11 | let numeroDeAnos = Number(inputAno.value); 12 | 13 | let total = numeroChinchilas; 14 | let quantidade = ''; 15 | 16 | if (numeroChinchilas < 2 || numeroDeAnos == 0 || isNaN(numeroChinchilas) || isNaN(numeroDeAnos)) { 17 | alert('Preencha os campos corretamente'); 18 | inputChinchilas.value = ''; 19 | inputAno.value = ''; 20 | inputChinchilas.focus(); 21 | return; 22 | } 23 | 24 | for (let index = 1; index <= numeroDeAnos; index++) { 25 | quantidade += `${index}º Ano: ${total} Chinchilas.\n`; 26 | total *= 3; 27 | 28 | } 29 | 30 | outChinchilas.textContent = quantidade; 31 | 32 | } 33 | 34 | btnChinchilas.addEventListener('click', mostarPrevisao); -------------------------------------------------------------------------------- /CriacaoDeChinchilas/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Chinchilas 9 | 10 | 11 |
12 |

Criação de Chinchilas

13 |
14 | 15 | 16 |
17 |
18 | 19 | 20 |
21 | 22 |
23 |

24 |         
25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /CriacaoDeChinchilas/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | border-bottom: 1px solid black; 22 | margin: 20px; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | padding: 5px; 32 | margin: 10px; 33 | width: 12.7em; 34 | } 35 | -------------------------------------------------------------------------------- /DescubraONumero/app.js: -------------------------------------------------------------------------------- 1 | const inputNumero = document.getElementById('inputNumero'); 2 | const btnApostar = document.getElementById('btnApostar'); 3 | const btnJogarNovamente = document.getElementById('btnJogarNovamente'); 4 | const outErros = document.getElementById('outErros'); 5 | const outChances = document.getElementById('outChances'); 6 | const outDica = document.getElementById('outDica'); 7 | 8 | let erros = []; 9 | let numeroGerado = Math.floor(Math.random() * 100) + 1; 10 | const numeroDeChances = 6; 11 | 12 | function apostarNumero() { 13 | 14 | let numeroApostado = Number(inputNumero.value); 15 | 16 | // checa a validade do número 17 | if (numeroApostado <= 0 || numeroApostado > 100 || isNaN(numeroApostado)) { 18 | alert('Digite um número válido'); 19 | inputNumero.value = ''; 20 | inputNumero.focus(); 21 | return; 22 | } 23 | 24 | // caso a pessoa acerte o número 25 | if (numeroApostado == numeroGerado) { 26 | 27 | alert('Parabéns você acertou o número !'); 28 | btnApostar.disabled = true; 29 | btnJogarNovamente.className = 'exibe'; 30 | outDica.textContent = `O número sorteado foi: ${numeroGerado}`; 31 | 32 | // caso não acerte, terá 2 opções: o número de chances acabar ou apostar um número repetido 33 | } else { 34 | 35 | // verifica se o número é repetido 36 | if (erros.indexOf(numeroApostado) >= 0) { 37 | 38 | alert(`Voê já apostou o número ${numeroApostado}. Tente outro número...`); 39 | 40 | // atualiza as chances até acabar as chances do jogador 41 | } else { 42 | 43 | erros.push(numeroApostado); 44 | let numeroDeErros = erros.length; 45 | let chancesRestantes = numeroDeChances - numeroDeErros; 46 | 47 | outErros.textContent = `${numeroDeErros} (${erros.join(', ')})`; 48 | outChances.textContent = chancesRestantes; 49 | 50 | if (chancesRestantes == 0) { 51 | 52 | alert('Suas chances acabaram, reinicie o jogo para tentar novamente !'); 53 | btnApostar.disabled = true; 54 | btnJogarNovamente.className = 'exibe'; 55 | outDica.textContent = `Game Over !! Número sorteado ${numeroGerado}`; 56 | 57 | // da uma dica se o número é maior ou menor do que o apostado. 58 | } else { 59 | 60 | let dica = numeroApostado < numeroGerado ? 'Maior' : 'Menor'; 61 | outDica.textContent = `Dica: tente um número ${dica} que o número ${numeroApostado}`; 62 | 63 | } 64 | } 65 | } 66 | inputNumero.value = ''; 67 | inputNumero.focus(); 68 | } 69 | 70 | btnApostar.addEventListener('click', apostarNumero); 71 | 72 | function reiniciarJogo() { 73 | location.reload(); 74 | } 75 | 76 | btnJogarNovamente.addEventListener('click', reiniciarJogo); -------------------------------------------------------------------------------- /DescubraONumero/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Descubra o Número 9 | 10 | 11 |
12 |

Descubra o Número

13 |
14 | 15 | 16 |
17 |
18 | 19 | 20 |
21 |
22 |

Erros: 0

23 |

Chances: 6

24 |

É um número entre 1 e 100.

25 |
26 |
27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /DescubraONumero/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | } 18 | 19 | h1 { 20 | margin: 10px; 21 | border-bottom: 1px solid black; 22 | } 23 | 24 | label { 25 | display: block; 26 | padding: 5px 0; 27 | } 28 | 29 | input[type="button"] { 30 | padding: 5px; 31 | margin: 10px 0; 32 | } 33 | 34 | .btnOculto { 35 | display: none; 36 | } 37 | 38 | .exibe { 39 | display: inline; 40 | } 41 | 42 | h3 { 43 | margin: 10px; 44 | } 45 | -------------------------------------------------------------------------------- /FabricaDeEstrelas/app.js: -------------------------------------------------------------------------------- 1 | const inputNumero = document.getElementById('inputNumero'); 2 | const btnEstrelas = document.getElementById('btnEstrelas'); 3 | const outEstrelas = document.getElementById('outEstrelas'); 4 | 5 | let estrelas = ''; 6 | 7 | function mostrarEstrelas() { 8 | 9 | let numeroDeEstrelas = Number(inputNumero.value); 10 | 11 | if (numeroDeEstrelas == 0 || isNaN(numeroDeEstrelas)) { 12 | alert('Digite um número'); 13 | inputNumero.value = ''; 14 | inputNumero.focus(); 15 | return; 16 | } 17 | 18 | for (let index = 1; index <= numeroDeEstrelas; index++) { 19 | 20 | if (index % 2 == 1) { 21 | estrelas += '*'; 22 | } else { 23 | estrelas += '-'; 24 | } 25 | 26 | } 27 | 28 | outEstrelas.textContent = estrelas; 29 | } 30 | 31 | btnEstrelas.addEventListener('click', mostrarEstrelas); -------------------------------------------------------------------------------- /FabricaDeEstrelas/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Fábrica de Estrelas 9 | 10 | 11 |
12 |

Fábrica de Estrelas

13 |
14 | 15 | 16 |
17 | 18 |
19 |

20 |
21 |
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /FabricaDeEstrelas/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | border-bottom: 1px solid black; 22 | margin: 20px; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | padding: 5px; 32 | margin: 10px; 33 | width: 12.7em; 34 | } 35 | -------------------------------------------------------------------------------- /FabricaDeEstrelas2/app.js: -------------------------------------------------------------------------------- 1 | const inputNumero = document.getElementById('inputNumero'); 2 | const btnEstrelas = document.getElementById('btnEstrelas'); 3 | const outEstrelas = document.getElementById('outEstrelas'); 4 | 5 | function mostrarEstrelas() { 6 | 7 | let numeroDeEstrelas = Number(inputNumero.value); 8 | let estrelas = ''; 9 | 10 | if (numeroDeEstrelas == 0 || numeroDeEstrelas == '' || isNaN(numeroDeEstrelas)) { 11 | alert('Preencha o campo corretamente !'); 12 | inputNumero.value = ''; 13 | inputNumero.focus(); 14 | return; 15 | } 16 | 17 | for (let index = 1; index <= numeroDeEstrelas; index++) { 18 | 19 | for (let j = 1; j <= index; j++) { 20 | estrelas += '*'; 21 | 22 | } 23 | estrelas += '\n'; 24 | } 25 | outEstrelas.textContent = estrelas; 26 | } 27 | 28 | btnEstrelas.addEventListener('click', mostrarEstrelas); -------------------------------------------------------------------------------- /FabricaDeEstrelas2/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Fábrica de Estrelas 9 | 10 | 11 |
12 |

Fábrica de Estrelas

13 |
14 | 15 | 16 |
17 | 18 |
19 |

20 |         
21 |
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /FabricaDeEstrelas2/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | border-bottom: 1px solid black; 22 | margin: 20px; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | padding: 5px; 32 | margin: 10px; 33 | width: 12.7em; 34 | } 35 | -------------------------------------------------------------------------------- /Farmacia/app.js: -------------------------------------------------------------------------------- 1 | const inputMedicamento = document.getElementById('inputMedicamento'); 2 | const inputPrecoDoMedicamento = document.getElementById('inputPrecoDoMedicamento'); 3 | const btnPreco = document.getElementById('btnPreco'); 4 | const outNomeDoMedicamento = document.getElementById('outNomeDoMedicamento'); 5 | const outPrecoDaPromocao = document.getElementById('outPrecoDaPromocao'); 6 | 7 | function CalcularPromocao() { 8 | 9 | let medicamento = inputMedicamento.value; 10 | let precoDoMedicamento = Number(Math.floor(inputPrecoDoMedicamento.value) * 2); 11 | 12 | outNomeDoMedicamento.textContent = `Promoção de ${medicamento}`; 13 | outPrecoDaPromocao.textContent = `Leve 2 pro R$ ${precoDoMedicamento}`; 14 | 15 | } 16 | 17 | btnPreco.addEventListener('click', CalcularPromocao); -------------------------------------------------------------------------------- /Farmacia/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Farmácia 10 | 11 | 12 |
13 |

Farmácia

14 |
15 | 16 | 17 |
18 |
19 | 20 | 21 |
22 | 23 |
24 |

25 |

26 |
27 |
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Farmacia/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | font-size: 3rem; 22 | margin: 10px; 23 | border-bottom: 1px solid black; 24 | } 25 | 26 | .labelMedicamento, 27 | .labelPreco { 28 | display: block; 29 | padding: 5px 0; 30 | } 31 | 32 | input[type="button"] { 33 | margin: 20px; 34 | padding: 5px; 35 | width: 12.5em; 36 | } -------------------------------------------------------------------------------- /FusoHorario/app.js: -------------------------------------------------------------------------------- 1 | const inputHorario = document.getElementById('inputHorario'); 2 | const btnFuso = document.getElementById('btnFuso'); 3 | const outHoraNoFuso = document.getElementById('outHoraNoFuso'); 4 | 5 | function calcularFuso() { 6 | 7 | let horario = Number(inputHorario.value); 8 | let horaFranca = (horario + 5).toFixed(2); // calcula a hora com o fuso +5; 9 | 10 | if (inputHorario.value == '' || isNaN(horario)) { 11 | alert('Digite um Horário válido !') 12 | inputHorario.focus(); 13 | return; 14 | } 15 | 16 | if (horaFranca > 24) { // se a hora com o fuso for maior que 24 17 | let horaFrancaFuso = (horaFranca - 24).toFixed(2); 18 | outHoraNoFuso.textContent = `Na França são ${horaFrancaFuso}`; 19 | } else { 20 | outHoraNoFuso.textContent = `Na França são ${horaFranca}`; 21 | } 22 | 23 | } 24 | 25 | btnFuso.addEventListener('click', calcularFuso); -------------------------------------------------------------------------------- /FusoHorario/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Fuso Horário 9 | 10 | 11 |
12 |

Fuso Horário

13 |
14 | 15 | 16 |
17 | 18 |
19 |

20 |
21 |
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /FusoHorario/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | } 18 | 19 | h1 { 20 | margin: 20px; 21 | border-bottom: 1px solid black; 22 | } 23 | 24 | label { 25 | display: block; 26 | padding: 5px 0; 27 | } 28 | 29 | input[type="button"] { 30 | margin: 20px; 31 | padding: 5px; 32 | width: 12.7em; 33 | } 34 | -------------------------------------------------------------------------------- /JogosEliminatorios/app.js: -------------------------------------------------------------------------------- 1 | const inputClube = document.getElementById('inputClube'); 2 | const btnAdicionar = document.getElementById('btnAdicionar'); 3 | const btnListar = document.getElementById('btnListar'); 4 | const btnTabela = document.getElementById('btnTabela'); 5 | const outLista = document.getElementById('outLista'); 6 | 7 | let todosClubes = [] 8 | 9 | // valida o preechimento, adiciona um clube ao array e lista os clubes 10 | function adicionarClube() { 11 | 12 | let clube = inputClube.value; 13 | 14 | if (clube == '') { 15 | alert('Preencha o campo corretamente!'); 16 | inputClube.value = ''; 17 | inputClube.focus(); 18 | return; 19 | } 20 | 21 | todosClubes.push(clube); 22 | inputClube.value = ''; 23 | inputClube.focus(); 24 | 25 | listarClube(); 26 | } 27 | 28 | btnAdicionar.addEventListener('click', adicionarClube); 29 | 30 | function listarClube() { 31 | 32 | if (todosClubes.length == 0) { 33 | alert('Não há clubes adicionados !'); 34 | return; 35 | } 36 | 37 | let listaDeClubes = ''; 38 | 39 | for (let index = 0; index < todosClubes.length; index++) { 40 | listaDeClubes += `${index + 1}. ${todosClubes[index]}\n` 41 | } 42 | 43 | outLista.textContent = listaDeClubes; 44 | } 45 | 46 | btnListar.addEventListener('click', listarClube); 47 | 48 | function mostarTabela() { 49 | 50 | let jogos = '' 51 | let ultimoClube = todosClubes[todosClubes.length - 1]; 52 | 53 | if ((todosClubes.length % 2) !== 0 || todosClubes.length == 0) { 54 | alert('Adicione mais um clube para poder montar a tabela de jogos !'); 55 | inputClube.focus(); 56 | return; 57 | } 58 | 59 | for (let index = 0; index < (todosClubes.length - 1) / 2; index++) { 60 | jogos += `${todosClubes[index]} x ${ultimoClube - index}\n`; 61 | } 62 | 63 | outLista.textContent = jogos; 64 | } 65 | 66 | btnTabela.addEventListener('click', mostarTabela); -------------------------------------------------------------------------------- /JogosEliminatorios/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Jogos Eliminatórios 9 | 10 | 11 |
12 |

Jogos Eliminatórios

13 |
14 | 15 | 16 |
17 | 18 | 19 | 20 |
21 |

22 |         
23 |
24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /JogosEliminatorios/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | border-bottom: 1px solid black; 22 | margin: 20px; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | padding: 5px; 32 | margin: 10px; 33 | width: 12.7em; 34 | } 35 | -------------------------------------------------------------------------------- /LadosDoTriangulo/app.js: -------------------------------------------------------------------------------- 1 | // Exerício para verificar a existência de um triângulo 2 | const inputLadoA = document.getElementById('inputLadoA'); 3 | const inputLadoB = document.getElementById('inputLadoB'); 4 | const inputLadoC = document.getElementById('inputLadoC'); 5 | const btnVerificarLados = document.getElementById('btnVerificarLados'); 6 | const outVerificado = document.getElementById('outVerificado'); 7 | const outTipoDeTriangulo = document.getElementById('outTipoDeTriangulo'); 8 | 9 | function verificarTriangulo() { 10 | 11 | let ladoA = Number(inputLadoA.value); 12 | let ladoB = Number(inputLadoB.value); 13 | let ladoC = Number(inputLadoC.value); 14 | 15 | // Verifica se existe algum triângulo 16 | if ((inputLadoA.value == 0 || inputLadoA.value == '') || (inputLadoB.value == 0 || inputLadoB.value == '') || (inputLadoC.value == 0 || inputLadoC.value == '') || isNaN(ladoA, ladoB, ladoC)) { 17 | 18 | alert('Digite para os lados do Triângulos números válido'); 19 | inputLadoA.value = ''; 20 | inputLadoB.value = ''; 21 | inputLadoC.value = ''; 22 | inputLadoA.focus(); 23 | return; 24 | 25 | } else if ((ladoA > ladoB + ladoC) || (ladoC > ladoB + ladoA) || (ladoB > ladoA + ladoC)) { 26 | outVerificado.textContent = `Esses Lados não podem formar um triângulo ! Escolha novamente os lados`; 27 | inputLadoA.value = ''; 28 | inputLadoB.value = ''; 29 | inputLadoC.value = ''; 30 | inputLadoA.focus(); 31 | return; 32 | } 33 | 34 | // Verifica o tipo de triângulo 35 | if ( (ladoA == ladoB) && (ladoC == ladoB) ) { 36 | 37 | outVerificado.textContent = `Esses Lados formam um triângulo`; 38 | outTipoDeTriangulo.textContent = `Tipo de Triângulo: Equilátero`; 39 | 40 | } else { 41 | if ((ladoA == ladoB) || (ladoA == ladoC) || (ladoC == ladoB)) { 42 | 43 | outVerificado.textContent = `Esses Lados formam um Triângulo`; 44 | outTipoDeTriangulo.textContent = `Tipo de Triângulo: Isósceles`; 45 | 46 | } else { 47 | 48 | outVerificado.textContent = `Esses Lados formam um triângulo`; 49 | outTipoDeTriangulo.textContent = `Tipo de Triângulo: Escaleno`; 50 | 51 | } 52 | } 53 | 54 | } 55 | 56 | btnVerificarLados.addEventListener('click', verificarTriangulo); -------------------------------------------------------------------------------- /LadosDoTriangulo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Lados do Triângulo 9 | 10 | 11 |
12 |

Lados de um Triângulo

13 |
14 | 15 | 16 |
17 |
18 | 19 | 20 |
21 |
22 | 23 | 24 |
25 | 26 |

27 |

28 |
29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /LadosDoTriangulo/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | margin: 20px; 22 | border-bottom: 1px solid black; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | margin: 10px; 32 | padding: 5px; 33 | width: 12.7em; 34 | } 35 | 36 | p { 37 | margin: 5px 0; 38 | } -------------------------------------------------------------------------------- /LanHouse/app.js: -------------------------------------------------------------------------------- 1 | const inputPrecoPorMin = document.getElementById('inputPrecoPorMin'); 2 | const inputTempoDeUso = document.getElementById('inputTempoDeUso'); 3 | const btnCalcular = document.getElementById('btnCalcular'); 4 | const outResultado = document.getElementById('outResultado'); 5 | 6 | function calcularPreco() { 7 | 8 | let precoPorMinuto = Number(inputPrecoPorMin.value); 9 | let tempoDeUso = Number(inputTempoDeUso.value); 10 | let tempoTotalDeUso = Math.ceil(tempoDeUso / 15); 11 | 12 | let precoTotal = (precoPorMinuto * tempoTotalDeUso).toFixed(2); 13 | 14 | outResultado.textContent = `Valor a Pagar: R$ ${precoTotal}`; 15 | } 16 | 17 | btnCalcular.addEventListener('click', calcularPreco); -------------------------------------------------------------------------------- /LanHouse/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Lan House 10 | 11 | 12 |
13 |

Lan House

14 |
15 | 16 | 17 |
18 |
19 | 20 | 21 |
22 | 23 |
24 |

25 |
26 |
27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /LanHouse/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: beige; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | font-size: 3rem; 22 | border-bottom: 1px solid black; 23 | margin: 20px; 24 | } 25 | 26 | label { 27 | display: block; 28 | padding: 5px 0; 29 | } 30 | 31 | input[type="button"] { 32 | padding: 5px; 33 | margin: 10px; 34 | width: 12.7em; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Locadora/app.js: -------------------------------------------------------------------------------- 1 | const inputFilme = document.getElementById('inputFilme'); 2 | const inputTempo = document.getElementById('inputTempo'); 3 | const btnConverter = document.getElementById('btnConverter'); 4 | const outFilme = document.getElementById('outFilme'); 5 | const outTempo = document.getElementById('outTempo'); 6 | 7 | function converterTempo() { 8 | 9 | let nomeDoFilme = inputFilme.value; 10 | let tempoDoFilme = Number(inputTempo.value); 11 | 12 | let horasDeDuração = Math.floor(tempoDoFilme / 60); // retorna a quantidade de horas 13 | let minutosDeDuração = tempoDoFilme % 60; // resto da divisão 14 | 15 | outFilme.textContent = nomeDoFilme; 16 | outTempo.textContent = `${horasDeDuração} hora(s) e ${minutosDeDuração} minuto(s)`; 17 | } 18 | 19 | btnConverter.addEventListener('click', converterTempo); -------------------------------------------------------------------------------- /Locadora/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Locadora 9 | 10 | 11 |
12 |

Vídeo Locadora

13 |
14 |
15 | 16 | 17 |
18 |
19 | 20 | 21 |
22 | 23 |
24 |

25 |

26 |
27 |
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Locadora/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: whitesmoke; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | font-size: 3rem; 22 | border-bottom: 1px solid black; 23 | margin-bottom: 10px; 24 | } 25 | 26 | .labelFilme, 27 | .labelTempo { 28 | display: block; 29 | padding: 5px 0; 30 | } 31 | 32 | input { 33 | outline: none; 34 | } 35 | 36 | input[type="button"] { 37 | margin: 20px; 38 | } 39 | -------------------------------------------------------------------------------- /MediaDoAluno/app.js: -------------------------------------------------------------------------------- 1 | const inputNomeDoAluno = document.getElementById('inputNomeDoAluno'); 2 | const inputNota1 = document.getElementById('inputNota1'); 3 | const inputNota2 = document.getElementById('inputNota2'); 4 | const btnMedia = document.getElementById('btnMedia'); 5 | const outMedia = document.getElementById('outMedia'); 6 | const resultado = document.getElementById('resultado'); 7 | 8 | function calcularMedia() { 9 | 10 | let nomeDoAluno = inputNomeDoAluno.value; 11 | let nota1 = Number(inputNota1.value); 12 | let nota2 = Number(inputNota2.value); 13 | let mediaFinal = ((nota1 + nota2) / 2).toFixed(1); 14 | 15 | if (mediaFinal >= 7) { 16 | outMedia.textContent = `Médias das Notas: ${mediaFinal}`; 17 | resultado.textContent = `Parabéns ${nomeDoAluno}, Você foi Aprovado !`; 18 | } else { 19 | outMedia.textContent = `Médias das Notas: ${mediaFinal}`; 20 | resultado.textContent = `${nomeDoAluno}, Você foi Reprovado !` 21 | } 22 | 23 | } 24 | 25 | btnMedia.addEventListener('click', calcularMedia); -------------------------------------------------------------------------------- /MediaDoAluno/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Média do Aluno 9 | 10 | 11 |
12 |

Média do Aluno

13 |
14 | 15 | 16 |
17 |
18 | 19 | 20 |
21 |
22 | 23 | 24 |
25 | 26 |
27 |

28 |

29 |
30 |
31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /MediaDoAluno/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: whitesmoke; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | margin: 20px; 22 | border-bottom: 1px solid black; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | margin: 20px; 32 | padding: 5px; 33 | width: 12.7em; 34 | } 35 | 36 | p { 37 | margin: 10px; 38 | } -------------------------------------------------------------------------------- /NumerosDecrescentes/app.js: -------------------------------------------------------------------------------- 1 | const inputNumero = document.getElementById('inputNumero'); 2 | const btnNumeroDecrescente = document.getElementById('btnNumeroDecrescente'); 3 | const outNumero = document.getElementById('outNumero'); 4 | 5 | function mostrarNumeros() { 6 | 7 | let numero = Number(inputNumero.value); 8 | let numerosDecrescentes = ''; 9 | let ultimoNumero = ''; 10 | 11 | if (inputNumero.value == '' || isNaN(numero)) { 12 | alert('Digite um número'); 13 | inputNumero.value = ''; 14 | inputNumero.focus(); 15 | return; 16 | } 17 | // verifica os números até o 2 18 | for (let index = numero; index > 1; index--) { 19 | numerosDecrescentes += `${index}, `; 20 | } 21 | // verifica o último número 22 | for (let index = numero - 1; index > 0 ; index--) { 23 | ultimoNumero = `${index}`; 24 | } 25 | 26 | outNumero.textContent = `Entre ${numero} e 1: ${numerosDecrescentes} ${ultimoNumero}.`; 27 | } 28 | 29 | btnNumeroDecrescente.addEventListener('click', mostrarNumeros); 30 | -------------------------------------------------------------------------------- /NumerosDecrescentes/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Números Decrescentes 9 | 10 | 11 |
12 |

Números Decrescentes

13 |
14 | 15 | 16 |
17 | 18 |
19 |

20 |
21 |
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /NumerosDecrescentes/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | border-bottom: 1px solid black; 22 | margin: 20px; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | padding: 5px; 32 | margin: 10px; 33 | width: 12.7em; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /NumerosEmOrdem/app.js: -------------------------------------------------------------------------------- 1 | // Verificar se os números estão em ordem crescente. 2 | 3 | const inputNumero = document.getElementById('inputNumero'); 4 | const btnAdicionar = document.getElementById('btnAdicionar'); 5 | const btnVerificar = document.getElementById('btnVerificar'); 6 | const outNumeros = document.getElementById('outNumeros'); 7 | const outTexto = document.getElementById('outTexto'); 8 | 9 | let todosNumeros = [] 10 | 11 | function adicionarNumero() { 12 | 13 | let numero = Number(inputNumero.value); 14 | 15 | if (inputNumero.value == '' || todosNumeros.indexOf(numero) >= 0 || isNaN(numero)) { 16 | alert('Digite um número válido !'); 17 | inputNumero.value = ''; 18 | inputNumero.focus(); 19 | return; 20 | } 21 | 22 | let listaDeNumeros = ''; 23 | todosNumeros.push(numero); 24 | let primeiroNumero = todosNumeros[0]; 25 | 26 | for (let index = 1; index < todosNumeros.length; index++) { 27 | listaDeNumeros += `, ${todosNumeros[index]}` 28 | } 29 | 30 | outNumeros.textContent = `Números: ${primeiroNumero}${listaDeNumeros}`; 31 | outTexto.textContent = ''; 32 | inputNumero.value = ''; 33 | inputNumero.focus(); 34 | 35 | } 36 | 37 | btnAdicionar.addEventListener('click', adicionarNumero); 38 | 39 | function verificarOrdem() { 40 | 41 | if (todosNumeros.length == 0) { 42 | alert('Adicione algum número !'); 43 | return; 44 | } 45 | 46 | for (let index = 0; index < todosNumeros.length -1; index++) { 47 | 48 | if (todosNumeros[index] < todosNumeros[index + 1]) { 49 | outTexto.textContent = 'Os números estão em ordem crescente.'; 50 | } else { 51 | outTexto.textContent = 'Atenção... Os números não estão em ordem crescente!'; 52 | } 53 | } 54 | } 55 | 56 | btnVerificar.addEventListener('click', verificarOrdem); -------------------------------------------------------------------------------- /NumerosEmOrdem/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Números em ordem 9 | 10 | 11 |
12 |

Números em ordem

13 |
14 | 15 | 16 |
17 |
18 | 19 | 20 |
21 |
22 |

23 |
24 |
25 |

26 |
27 |
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /NumerosEmOrdem/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | border-bottom: 1px solid black; 22 | margin: 20px; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | display: block; 32 | padding: 5px; 33 | margin: 10px; 34 | width: 12.7em; 35 | } 36 | -------------------------------------------------------------------------------- /NumerosPerfeitos/app.js: -------------------------------------------------------------------------------- 1 | const inputNumero = document.getElementById('inputNumero'); 2 | const btnNumero = document.getElementById('btnNumero'); 3 | const outNumero = document.getElementById('outNumero'); 4 | 5 | function verificarNumero() { 6 | 7 | let numero = Number(inputNumero.value); 8 | 9 | let divisores = `Divisores do ${numero} : 1`; 10 | let soma = 1; 11 | 12 | for (let index = 2; index <= numero / 2; index++) { 13 | if (numero % index == 0) { 14 | divisores += `, ${index}`; 15 | soma += index; 16 | } 17 | } 18 | divisores += `. (Soma: ${soma})` 19 | outNumero.textContent = divisores; 20 | 21 | if (numero == soma) { 22 | outNumero.textContent = `${divisores}. Logo, É um número Perfeito`; 23 | } else { 24 | outNumero.textContent = `${divisores}. Logo, Não é um número perfeito`; 25 | } 26 | } 27 | 28 | btnNumero.addEventListener('click', verificarNumero); -------------------------------------------------------------------------------- /NumerosPerfeitos/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Números Perfeitos 9 | 10 | 11 |
12 |

Números Perfeitos

13 |
14 | 15 | 16 |
17 | 18 |
19 |

20 |
21 |
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /NumerosPerfeitos/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | border-bottom: 1px solid black; 22 | margin: 20px; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | padding: 5px; 32 | margin: 10px; 33 | width: 12.7em; 34 | } 35 | -------------------------------------------------------------------------------- /NumerosPrimos/app.js: -------------------------------------------------------------------------------- 1 | const inputNumero = document.getElementById('inputNumero'); 2 | const btnNumero = document.getElementById('btnNumero'); 3 | const outNumero = document.getElementById('outNumero'); 4 | 5 | let numeroDeDivisores = 0; 6 | 7 | function verificarNumero() { 8 | 9 | let numero = Number(inputNumero.value); 10 | 11 | for (let index = 2; index <= numero / 2; index++) { 12 | if ((numero % index) == 0) { 13 | numeroDeDivisores = 1; 14 | break; 15 | } 16 | } 17 | 18 | if (numero > 1 && !numeroDeDivisores) { 19 | outNumero.textContent = `Esse número é primo !` 20 | } else { 21 | outNumero.textContent = `${numero} não é primo` 22 | } 23 | 24 | } 25 | 26 | btnNumero.addEventListener('click', verificarNumero); -------------------------------------------------------------------------------- /NumerosPrimos/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Números Primos 9 | 10 | 11 |
12 |

Números Primos

13 |
14 | 15 | 16 |
17 | 18 |
19 |

20 |
21 |
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /NumerosPrimos/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | border-bottom: 1px solid black; 22 | margin: 20px; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | padding: 5px; 32 | margin: 10px; 33 | width: 12.7em; 34 | } 35 | -------------------------------------------------------------------------------- /ParOuImpar/app.js: -------------------------------------------------------------------------------- 1 | const inputNumero = document.getElementById('inputNumero'); 2 | const btnNumero = document.getElementById('btnNumero'); 3 | const outNumero = document.getElementById('outNumero'); 4 | 5 | // Verifica se o número escolhido é par ou ímpar 6 | function verificarNumero() { 7 | 8 | let numero = inputNumero.value; 9 | 10 | if ((numero < 0 || numero == '') || isNaN(numero)) { 11 | alert('Digite um número positivo válido !'); 12 | inputNumero.value = ''; 13 | inputNumero.focus(); 14 | return; 15 | 16 | } else if (numero % 2 !== 0) { 17 | outNumero.textContent = `O número ${numero} é Ímpar`; 18 | } else { 19 | outNumero.textContent = `O número ${numero} é Par`; 20 | } 21 | 22 | } 23 | 24 | btnNumero.addEventListener('click', verificarNumero); -------------------------------------------------------------------------------- /ParOuImpar/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Número Par ou Ímpar 9 | 10 | 11 |
12 |

Par ou ímpar ?

13 |
14 | 15 | 16 |
17 | 18 |
19 |

20 |
21 |
22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ParOuImpar/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: beige; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | margin: 20px; 22 | border-bottom: 1px solid black; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | padding: 5px; 32 | margin: 20px; 33 | width: 12.7em; 34 | } -------------------------------------------------------------------------------- /Parquimetro/app.js: -------------------------------------------------------------------------------- 1 | // valor do parquimetro R$1.00 - 30min 2 | // valor do parquimetro R$1.75 - 60min 3 | // valor do parquimetro R$3.00 - 120min 4 | 5 | const inputValorPago = document.getElementById('inputValorPagado'); 6 | const btnParquimetro = document.getElementById('btnParquimetro'); 7 | const outTempoDeUso = document.getElementById('outTempoDeUso'); 8 | const outTroco = document.getElementById('outTroco'); 9 | 10 | function parquimetro() { 11 | 12 | // pega o valor do input e calcula o troco do cliente 13 | let valorPago = Number(inputValorPagado.value); 14 | let trocoDe30min = (valorPago - 1).toFixed(2); 15 | let trocoDe60min = (valorPago - 1.75).toFixed(2); 16 | let trocoDe120min = (valorPago - 3).toFixed(2); 17 | 18 | if ((inputValorPagado.value == '' || inputValorPagado.value < 1) || isNaN(valorPago)) { 19 | alert('Digite um valor mínimo de R$1.00 !'); 20 | inputValorPago.value = ''; 21 | inputValorPago.focus(); 22 | return 23 | } 24 | 25 | if (valorPago >= 1 && valorPago < 1.75) { 26 | outTempoDeUso.textContent = `Tempo: 30min`; 27 | outTroco.textContent = `Troco: ${trocoDe30min}`; 28 | } else if (valorPago >= 1.75 && valorPago < 3) { 29 | outTempoDeUso.textContent = `Tempo: 60min`; 30 | outTroco.textContent = `Troco: ${trocoDe60min}`; 31 | } else { 32 | outTempoDeUso.textContent = `Tempo: 120min`; 33 | outTroco.textContent = `Troco: ${trocoDe120min}`; 34 | } 35 | } 36 | 37 | btnParquimetro.addEventListener('click', parquimetro); -------------------------------------------------------------------------------- /Parquimetro/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Parquimetro 9 | 10 | 11 |
12 |

Parquímetro

13 |
14 | 15 | 16 |
17 | 18 |
19 |

20 |

21 |
22 |
23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Parquimetro/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | margin: 20px; 22 | padding: 5px 0; 23 | border-bottom: 1px solid black; 24 | } 25 | 26 | label { 27 | display: block; 28 | padding: 5px 0; 29 | } 30 | 31 | input[type="button"] { 32 | margin: 20px; 33 | padding: 5px; 34 | width: 12.7em; 35 | } -------------------------------------------------------------------------------- /PesoIdeal/app.js: -------------------------------------------------------------------------------- 1 | const inputNome = document.getElementById('inputNome'); 2 | const inputAltura = document.getElementById('inputAltura'); 3 | const inputMasculino = document.getElementById('masculino'); 4 | const inputFeminino = document.getElementById('feminino'); 5 | const btnCalcular = document.getElementById('btnCalcularPeso'); 6 | const btnLimpar = document.getElementById('btnLimpar'); 7 | const outResultadoDoPeso = document.getElementById('outResultadoDoPeso'); 8 | 9 | // Peso ideal do Homem = 22 * altura² 10 | // Peso ideal da Mulher = 21 * altura² 11 | 12 | function pesoIdeal() { 13 | 14 | let nome = inputNome.value; 15 | let altura = Number(inputAltura.value); 16 | let masculino = inputMasculino.checked; 17 | let feminino = inputFeminino.checked; 18 | 19 | let pesoMasculino = (22 * Math.pow(altura, 2)).toFixed(2); 20 | let pesoFeminino = (21 * Math.pow(altura, 2)).toFixed(2); 21 | 22 | // checa se o campo do nome ou os inputs estão vazios 23 | if (nome == '' || (masculino == false && feminino == false)) { 24 | alert('Digite o seu nome e selecione o sexo !'); 25 | inputNome.focus(); 26 | return; 27 | } 28 | // checa se a altura é igual a Zero ou se não é um número 29 | if (altura == 0 || isNaN(altura)) { 30 | alert('Digite sua Altura !'); 31 | inputAltura.focus(); 32 | return; 33 | } 34 | // executa quando tudo estiver ok 35 | if (masculino) { 36 | outResultadoDoPeso.textContent = `O seu peso ideal é: ${pesoMasculino} Kgs`; 37 | } else { 38 | outResultadoDoPeso.textContent = `O seu peso ideal é: ${pesoFeminino} Kgs`; 39 | } 40 | 41 | } 42 | 43 | btnCalcular.addEventListener('click', pesoIdeal); 44 | 45 | function limparCampos() { 46 | inputNome.value = ''; 47 | inputAltura.value = ''; 48 | inputMasculino.checked = false; 49 | inputFeminino.checked = false; 50 | outResultadoDoPeso.textContent = ''; 51 | inputNome.focus(); 52 | } 53 | 54 | btnLimpar.addEventListener('click', limparCampos); -------------------------------------------------------------------------------- /PesoIdeal/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Calculadora de Peso 9 | 10 | 11 |
12 |
13 |

Programa Cálculo do Peso

14 |
15 | 16 | 17 |
18 |
19 | 20 |

Masculino

21 |

Feminino

22 |
23 |
24 | 25 | 26 |
27 |
28 | 29 | 30 |
31 |
32 |

33 |
34 |
35 |
36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /PesoIdeal/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | } 18 | 19 | .row { 20 | display: flex; 21 | align-items: center; 22 | justify-content: center; 23 | flex-direction: column; 24 | height: 100vh; 25 | } 26 | 27 | h1 { 28 | margin: 20px; 29 | border-bottom: 1px solid black; 30 | } 31 | 32 | label { 33 | display: block; 34 | padding: 5px 0; 35 | } 36 | 37 | input[type="button"] { 38 | display: inline-block; 39 | } 40 | 41 | .sexoDaPessoa { 42 | display: inline-block; 43 | padding: 5px 5px 5px 0; 44 | } 45 | 46 | input[type="radio"] { 47 | margin: 5px 5px 5px 0; 48 | } 49 | 50 | input[type="button"] { 51 | padding: 5px; 52 | margin: 20px 0; 53 | } -------------------------------------------------------------------------------- /ProgramaBrinquedoteca/app.js: -------------------------------------------------------------------------------- 1 | const inputCrianca = document.getElementById('inputCrianca'); 2 | const inputIdade = document.getElementById('inputIdade'); 3 | const btnAdicionar = document.getElementById('btnAdicionar'); 4 | const btnListar = document.getElementById('btnListar'); 5 | const btnFiltar = document.getElementById('btnFiltar'); 6 | const outLista = document.getElementById('outLista'); 7 | 8 | let criancas = []; 9 | 10 | function adicionarBrinquedo() { 11 | 12 | let nome = inputCrianca.value; 13 | let idade = Number(inputIdade.value); 14 | 15 | if (nome == '' || idade == 0 || idade == '' || isNaN(idade)) { 16 | alert('Preencha os campos corretamente'); 17 | inputCrianca.value = ''; 18 | inputIdade.value = ''; 19 | inputCrianca.focus(); 20 | return; 21 | } 22 | 23 | criancas.push({ nome: nome, idade: idade }); 24 | 25 | inputCrianca.value = ''; 26 | inputIdade.value = ''; 27 | inputCrianca.focus(); 28 | 29 | listarCriancas(); 30 | } 31 | 32 | btnAdicionar.addEventListener('click', adicionarBrinquedo); 33 | 34 | function listarCriancas() { 35 | 36 | if (criancas.length == 0) { 37 | alert('Não há crianças cadastradas!'); 38 | return; 39 | } 40 | 41 | let lista = ''; 42 | 43 | for (let index = 0; index < criancas.length; index++) { 44 | lista += `${criancas[index].nome} - ${criancas[index].idade} anos \n`; 45 | } 46 | 47 | outLista.textContent = lista; 48 | 49 | } 50 | 51 | btnListar.addEventListener('click', listarCriancas); 52 | 53 | function resumirIdade() { 54 | 55 | if (criancas.length == 0) { 56 | alert('Não há crianças na lista !'); 57 | return; 58 | } 59 | 60 | let copia = criancas.slice(); 61 | 62 | copia.sort(function (a, b) { 63 | return a.idade - b.idade 64 | }); 65 | 66 | let resumo = ''; 67 | 68 | let menorIdade = copia[0].idade; 69 | let nomes = []; 70 | 71 | for (let index = 0; index < copia.length; index++) { 72 | 73 | if (copia[index].idade == menorIdade) { 74 | 75 | nomes.push(copia[index].nome) 76 | 77 | } else { 78 | 79 | resumo += `${menorIdade} ano(s): ${nomes.length} crianças - `; 80 | resumo += `${(nomes.length / copia.length * 100).toFixed(2)} % \n`; 81 | resumo += `(${nomes.join(', ')}) \n\n`; 82 | menorIdade = copia[index].idade; 83 | nomes = []; 84 | nomes.push(copia[index].nome); 85 | 86 | } 87 | } 88 | resumo += `${menorIdade} ano(s) ${nomes.length} crianças - `; 89 | resumo += `${(nomes.length / copia.length * 100).toFixed(2)} % \n`; 90 | resumo += `(${nomes.join(', ')}) \n \n`; 91 | 92 | outLista.textContent = resumo; 93 | 94 | } 95 | 96 | btnFiltar.addEventListener('click', resumirIdade); -------------------------------------------------------------------------------- /ProgramaBrinquedoteca/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Programa Brinquedoteca 9 | 10 | 11 |
12 |

Programa Brinquedoteca

13 |
14 | 15 | 16 |
17 |
18 | 19 | 20 |
21 | 22 | 23 | 24 |
25 |

26 |         
27 |
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /ProgramaBrinquedoteca/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | border-bottom: 1px solid black; 22 | margin: 20px; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | padding: 5px; 32 | margin: 10px; 33 | width: 12.7em; 34 | } 35 | -------------------------------------------------------------------------------- /ProgramaConcurso/app.js: -------------------------------------------------------------------------------- 1 | const inputCandidato = document.getElementById('inputCandidato'); 2 | const inputAcertos = document.getElementById('inputAcertos'); 3 | const btnAdicionar = document.getElementById('btnAdicionar'); 4 | const btnListar = document.getElementById('btnListar'); 5 | const btnAprovados = document.getElementById('btnAprovados'); 6 | const outAcertos = document.getElementById('outAcertos'); 7 | 8 | let candidatosAcertos = []; 9 | 10 | function adicionar() { 11 | 12 | let candidato = inputCandidato.value; 13 | 14 | let acertos = Number(inputAcertos.value); 15 | 16 | if ((candidato == '') || (acertos == '') || isNaN(acertos)) { 17 | alert('Preencha os campos corretamente!'); 18 | inputCandidato.focus(); 19 | return; 20 | } 21 | 22 | candidatosAcertos.push({ nome: candidato, acertos: acertos }); 23 | 24 | inputCandidato.value = ''; 25 | inputAcertos.value = ''; 26 | inputCandidato.focus(); 27 | 28 | listarTodos(); 29 | } 30 | 31 | btnAdicionar.addEventListener('click', adicionar); 32 | 33 | function listarTodos() { 34 | 35 | if (candidatosAcertos.length == 0) { 36 | alert('Não há dados de nenhum candidato!'); 37 | return; 38 | } 39 | 40 | let lista = ''; 41 | 42 | for (let index = 0; index < candidatosAcertos.length; index++) { 43 | lista += `${index + 1}º - ${candidatosAcertos[index].nome} - ${candidatosAcertos[index].acertos} acertos\n`; 44 | } 45 | 46 | outAcertos.textContent = lista; 47 | 48 | } 49 | 50 | btnListar.addEventListener('click', listarTodos); 51 | 52 | function todosAprovados() { 53 | 54 | if (candidatosAcertos.length == 0) { 55 | alert('Não há candidatos! Adicione os candidatos.'); 56 | inputCandidato.focus(); 57 | return; 58 | } 59 | 60 | let acertosParaAprovar = Number(prompt('Os aprovados devem acertar pelo menos:')); 61 | 62 | if ((acertosParaAprovar == 0) || isNaN(acertosParaAprovar)) { 63 | alert('Número inválido!'); 64 | return; 65 | } 66 | 67 | let copia = candidatosAcertos.slice(); 68 | copia.sort( function (a, b) { 69 | return a.acertos - b.acertos; 70 | }); 71 | copia.reverse(); 72 | 73 | let aprovados = ''; 74 | 75 | for (let index = 0; index < copia.length; index++) { 76 | if (copia[index].acertos >= acertosParaAprovar) { 77 | aprovados += `${index + 1}º Colocado - ${copia[index].nome} - ${copia[index].acertos} acertos\n`; 78 | } 79 | } 80 | 81 | if (aprovados == '') { 82 | outAcertos.textContent = 'Não há aprovados no concurso!'; 83 | } else { 84 | outAcertos.textContent = aprovados; 85 | } 86 | } 87 | 88 | btnAprovados.addEventListener('click', todosAprovados); -------------------------------------------------------------------------------- /ProgramaConcurso/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Programa Concurso 9 | 10 | 11 |
12 |

Programa Concurso

13 |
14 | 15 | 16 |
17 |
18 | 19 | 20 |
21 | 22 | 23 | 24 |
25 |

26 |         
27 |
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /ProgramaConcurso/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | border-bottom: 1px solid black; 22 | margin: 20px; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | cursor: pointer; 32 | padding: 5px; 33 | margin: 10px; 34 | width: 12.7em; 35 | } 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Questões-Lógica-de-programação-e-algoritmos-com-javascript-novatec 2 | 3 | Resoluções das questões e exemplos do livro **_Lógica de programação e Algoritmos com Javascript_** da Editora NOVATEC; Autor: Edécio Fernando Iepsen. 4 | 5 | As resoluções Oficiais feitas pelo autor do livro podem ser baixadas clicando em **_EXEMPLOS DO LIVRO_** na aba **_SUPORTE_** no [SITE OFICIAL DA NOVATEC](https://novatec.com.br/livros/logica-programacao-algoritmos-com-javascript/). 6 | 7 | ## Questões por Capítulo 8 | O **capítulo 1** é uma introdução a lógica de programação e algoritimos, uma apresentação dos conceitos básicos do JavaScript como variáveis, uma explicação de como instalar um editor de código; no caso do livro o [Visual Studio Code](https://code.visualstudio.com/). 9 | 10 | **Capítulo 2** - **_Integração com HTML_** 11 | 12 | [Locadora](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/Locadora); 13 | 14 | [Revenda de Veículos](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/RevendaDeVeiculos); 15 | 16 | [Restaurante](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/Restaurante); 17 | 18 | [Farmácia](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/Farmacia); 19 | 20 | [Lan House](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/LanHouse); 21 | 22 | [Supermercado](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/Supermercado); 23 | 24 | **Capítulo 3** - **_Condicionais_** 25 | 26 | [Peso Ideal](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/PesoIdeal); 27 | 28 | [Fuso Horário](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/FusoHorario); 29 | 30 | [Raiz Quadrada](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/RaizQuadrada); 31 | 32 | [Caixa Eletrônico](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/CaixaEletronico); 33 | 34 | [Par ou Ímpar](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/ParOuImpar); 35 | 36 | [Verifica Velocidade](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/VerificaVelocidade); 37 | 38 | [Parquímetro](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/Parquimetro); 39 | 40 | [Lados do Triângulo](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/LadosDoTriangulo); 41 | 42 | **Capítulo 4** - **_Repetições_** 43 | 44 | [Tabuada](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/Tabuada); 45 | 46 | [Números Decrescentes](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/NumerosDecrescentes); 47 | 48 | [Contas do Mês](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/ContasDoMes); 49 | 50 | [Números Primos](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/NumerosPrimos); 51 | 52 | [Fábrica de Estrelas](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/FabricaDeEstrelas); 53 | 54 | [Repete Fruta](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/RepeteFruta); 55 | 56 | [Criação de Chinchilas](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/CriacaoDeChinchilas); 57 | 58 | [Números Perfeitos](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/NumerosPerfeitos); 59 | 60 | [Fábrica de Estrelas 2](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/FabricaDeEstrelas2); 61 | 62 | **Capítulo 5** - **_Arrays / Vetores_** 63 | 64 | [Consultório Odontológico](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/ConsultorioOdontologico); 65 | 66 | [Descubra o Número](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/DescubraONumero); 67 | 68 | [Revenda Herbie](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/RevendaHerbie); 69 | 70 | [Brinquedoteca](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/ProgramaBrinquedoteca); 71 | 72 | [Jogos Eliminatórios](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/JogosEliminatorios); 73 | 74 | [Números em Ordem](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/NumerosEmOrdem); 75 | 76 | [Programa Concurso](https://github.com/gabrielmxavier/questoes-Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/ProgramaConcurso); 77 | 78 | [Últimas Notícias](https://github.com/gabrielmxavier/Logica-de-programacao-e-algoritmos-com-javascript-novatec/tree/master/UltimasNoticias); 79 | 80 | **Capítulo 6** - **_Strings e Datas_** 81 | 82 | Em breve será adicionado os exercícios deste capítulo. 83 | -------------------------------------------------------------------------------- /RaizQuadrada/app.js: -------------------------------------------------------------------------------- 1 | const inputNumero = document.getElementById('inputNumero'); 2 | const btnRaiz = document.getElementById('btnRaiz'); 3 | const outRaiz = document.getElementById('outRaiz'); 4 | 5 | function calcularRaiz() { 6 | 7 | let numero = Number(inputNumero.value); 8 | let raiz = Math.sqrt(numero); 9 | 10 | if ((inputNumero.value == 0 || inputNumero.value == '' ) || isNaN(numero)) { 11 | alert('Digite um número !'); 12 | inputNumero.focus(); 13 | return; 14 | } else if (raiz == Math.floor(raiz)) { 15 | outRaiz.textContent = `A raiz quadrada de ${numero} é ${raiz}`; 16 | } else { 17 | outRaiz.textContent = `O número ${numero} não possui raiz quadrada`; 18 | } 19 | 20 | } 21 | 22 | btnRaiz.addEventListener('click', calcularRaiz); -------------------------------------------------------------------------------- /RaizQuadrada/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Raiz Quadrada 9 | 10 | 11 |
12 |

Raiz Quadrada

13 |
14 | 15 | 16 |
17 | 18 |
19 |

20 |
21 |
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /RaizQuadrada/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: burlywood; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | margin: 20px; 22 | border-bottom: 1px solid black; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | margin: 20px; 32 | padding: 5px; 33 | width: 12.7em; 34 | } -------------------------------------------------------------------------------- /RepeteFruta/app.js: -------------------------------------------------------------------------------- 1 | const inputFruta = document.getElementById('inputFruta'); 2 | const inputNumero = document.getElementById('inputNumero'); 3 | const btnFruta = document.getElementById('btnFruta'); 4 | const outFruta = document.getElementById('outFrutas'); 5 | 6 | 7 | function mostrarFruta() { 8 | 9 | let fruta = inputFruta.value; 10 | let numero = Number(inputNumero.value); 11 | let frutaRepitida = ''; 12 | let ultimaFruta = ''; 13 | 14 | if (fruta == '' || numero == 0 || isNaN(numero)) { 15 | alert('Preencha os campos corretamente...'); 16 | inputFruta.focus(); 17 | inputFruta.value = ''; 18 | inputNumero.value = ''; 19 | outFruta.textContent = ''; 20 | return; 21 | } 22 | 23 | // Imprimi todas as frutas menos 1 24 | for (let index = 2; index <= numero; index++) { 25 | frutaRepitida += `${fruta}*`; 26 | } 27 | 28 | // imprimi a unica fruta que não foi impressa no loop FOR, uma vez que foi iniciado no index = 2 e não 1 29 | ultimaFruta = `${fruta}`; 30 | 31 | outFruta.textContent = `${frutaRepitida}${ultimaFruta}`; 32 | } 33 | 34 | btnFruta.addEventListener('click', mostrarFruta); -------------------------------------------------------------------------------- /RepeteFruta/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Frutas 9 | 10 | 11 |
12 |

Repete Frutas

13 |
14 | 15 | 16 |
17 |
18 | 19 | 20 |
21 | 22 |
23 |

24 |
25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /RepeteFruta/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | border-bottom: 1px solid black; 22 | margin: 20px; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | padding: 5px; 32 | margin: 10px; 33 | width: 12.7em; 34 | } 35 | -------------------------------------------------------------------------------- /Restaurante/app.js: -------------------------------------------------------------------------------- 1 | const inputPrecoPorQuilo = document.getElementById('inputPrecoPorQuilo'); 2 | const inputPeso = document.getElementById('inputPeso'); 3 | const btnPreco = document.getElementById('btnPreco'); 4 | const outTotalAPagar = document.getElementById('outTotalAPagar'); 5 | 6 | function CalcularPreco() { 7 | 8 | let preco = Number(inputPrecoPorQuilo.value).toFixed(2); 9 | let peso = Number(inputPeso.value / 1000); 10 | let precoTotal = (preco * peso).toFixed(2); 11 | 12 | outTotalAPagar.textContent = `Preço total: R$ ${precoTotal}`; 13 | 14 | } 15 | 16 | btnPreco.addEventListener('click', CalcularPreco); -------------------------------------------------------------------------------- /Restaurante/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Restaurante 10 | 11 | 12 |
13 |

Restaurante

14 |
15 | 16 | 17 |
18 |
19 | 20 | 21 |
22 | 23 |
24 |

25 |
26 |
27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Restaurante/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: cornsilk; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | margin: 20px; 22 | font-size: 3rem; 23 | border-bottom: 1px solid black; 24 | } 25 | 26 | .labelPreco, 27 | .labelPeso { 28 | display: block; 29 | padding: 5px 0; 30 | } 31 | 32 | input[type="button"] { 33 | cursor: pointer; 34 | margin: 20px; 35 | padding: 5px; 36 | width: 13em; 37 | } 38 | 39 | -------------------------------------------------------------------------------- /RevendaDeVeiculos/app.js: -------------------------------------------------------------------------------- 1 | const inputCarro = document.getElementById('inputCarro'); 2 | const inputPreco = document.getElementById('inputPreco'); 3 | const btnCalcularPreco = document.getElementById('btnCalcularPreco'); 4 | const outNomeDoCarro = document.getElementById('outNomeDoCarro'); 5 | const outValorDaEntrada = document.getElementById('outValorDaEntrada'); 6 | const outValorDasParcelas = document.getElementById('outValorDasParcelas'); 7 | 8 | function calcularPreco() { 9 | 10 | let nomeDoCarro = inputCarro.value; 11 | let precoDoCarro = Number(inputPreco.value); 12 | 13 | let valorDaEntrada = (precoDoCarro * 0.3).toFixed(2); 14 | let valorDasParcelas = ((precoDoCarro - valorDaEntrada) / 12).toFixed(2); 15 | 16 | outNomeDoCarro.textContent = nomeDoCarro; 17 | outValorDaEntrada.textContent = `R$ ${valorDaEntrada}`; 18 | outValorDasParcelas.textContent = `12 parcelas de: R$ ${valorDasParcelas}`; 19 | 20 | } 21 | 22 | btnCalcularPreco.addEventListener('click', calcularPreco); -------------------------------------------------------------------------------- /RevendaDeVeiculos/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Revenda 10 | 11 | 12 |
13 |

Revendedora de Veículos

14 |
15 | 16 | 17 |
18 |
19 | 20 | 21 |
22 | 23 |
24 |

25 |

26 |

27 |
28 |
29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /RevendaDeVeiculos/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: aliceblue; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | } 18 | 19 | h1 { 20 | margin-bottom: 20px; 21 | font-size: 3rem; 22 | border-bottom: 1px solid black; 23 | } 24 | 25 | .labelCarro, 26 | .labelPreco { 27 | display: block; 28 | padding: 5px 0; 29 | } 30 | 31 | input { 32 | outline: none; 33 | } 34 | 35 | input[type="button"] { 36 | margin: 20px; 37 | } -------------------------------------------------------------------------------- /RevendaHerbie/app.js: -------------------------------------------------------------------------------- 1 | const inputModeloCarro = document.getElementById('inputModeloCarro'); 2 | const inputPreco = document.getElementById('inputPreco'); 3 | const btnAdicionar = document.getElementById('btnAdicionar'); 4 | const btnListar = document.getElementById('btnListar'); 5 | const btnFiltar = document.getElementById('btnFiltar'); 6 | const outLista = document.getElementById('outLista'); 7 | 8 | let carros = []; 9 | 10 | function adicionarCarro() { 11 | 12 | modeloCarro = inputModeloCarro.value; 13 | precoCarro = Number(inputPreco.value); 14 | 15 | // verifica a validade dos dados 16 | if (modeloCarro == '' || precoCarro == 0 || isNaN(precoCarro)) { 17 | alert('Preencha corretamente os dados !'); 18 | inputModeloCarro.value = ''; 19 | inputPreco.value = ''; 20 | inputModeloCarro.focus(); 21 | return; 22 | } 23 | 24 | // adiciona no array o carro e o preço 25 | carros.push({ modelo: modeloCarro, preco: precoCarro }); 26 | 27 | inputModeloCarro.value = ''; 28 | inputPreco.value = ''; 29 | inputModeloCarro.focus(); 30 | 31 | listarCarros(); 32 | } 33 | 34 | btnAdicionar.addEventListener('click', adicionarCarro); 35 | 36 | function listarCarros() { 37 | 38 | if (carros.length == 0) { 39 | alert('Não há carros listado!'); 40 | return; 41 | } 42 | 43 | let lista = ''; 44 | 45 | for (let index = 0; index < carros.length; index++) { 46 | 47 | // adiciona os carros á listagem 48 | lista += `${carros[index].modelo} - R$: ${(carros[index].preco).toFixed(2)}\n`; 49 | 50 | } 51 | 52 | outLista.textContent = lista; 53 | } 54 | 55 | btnListar.addEventListener('click', listarCarros); 56 | 57 | function filtrarCarros() { 58 | 59 | let valorMaximo = Number(prompt('Qual a faixa de preço do carro que procura ?')); 60 | 61 | if (valorMaximo == 0 || isNaN(valorMaximo)) { 62 | return; 63 | } 64 | 65 | let lista = ''; 66 | 67 | for (let index = 0; index < carros.length; index++) { 68 | 69 | // verifica se o preço do carro é menor ou igual ao informado pelo cliente 70 | if (carros[index].preco <= valorMaximo) { 71 | lista += `${carros[index].modelo} - R$: ${(carros[index].preco).toFixed(2)}\n`; 72 | } 73 | 74 | if (lista == '') { 75 | 76 | outLista.textContent = `Não há carros na faxia de R$: ${(valorMaximo).toFixed(2)}`; 77 | 78 | } else { 79 | 80 | outLista.textContent = `Carros com preço até R$: ${valorMaximo.toFixed(2)}\n ------------------ \n${lista}\n`; 81 | } 82 | } 83 | } 84 | 85 | btnFiltar.addEventListener('click', filtrarCarros); 86 | -------------------------------------------------------------------------------- /RevendaHerbie/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Revenda Herbie 9 | 10 | 11 |
12 |

Revenda Herbie

13 |
14 | 15 | 16 |
17 |
18 | 19 | 20 |
21 | 22 | 23 | 24 |
25 |

26 |         
27 |
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /RevendaHerbie/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | border-bottom: 1px solid black; 22 | margin: 20px; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | padding: 5px; 32 | margin: 10px; 33 | width: 12.7em; 34 | } 35 | -------------------------------------------------------------------------------- /Supermercado/app.js: -------------------------------------------------------------------------------- 1 | // 2 vezes o preço do produto mais metado do preço 2 | 3 | const inputProduto = document.getElementById('inputProduto'); 4 | const inputPrecoDoProduto = document.getElementById('inputPrecoDoProduto'); 5 | const btnPreco = document.getElementById('btnPreco'); 6 | const outPromocao = document.getElementById('outPromocao'); 7 | const outPrecoDoProduto3 = document.getElementById('outPrecoDoProduto3'); 8 | 9 | function calcularPreco() { 10 | 11 | let nomeDoProduto = inputProduto.value; 12 | let precoDoProduto = Number(inputPrecoDoProduto.value); 13 | 14 | let precoDaPromocao = ((precoDoProduto * 2) + (precoDoProduto * 0.5)).toFixed(2); 15 | let precoDoProduto3 = (precoDoProduto * 0.5).toFixed(2); 16 | 17 | outPromocao.textContent = `${nomeDoProduto} - Promoção: Leve 3 por: R$ ${precoDaPromocao}`; 18 | outPrecoDoProduto3.textContent = `O 3º produto sai por: R$ ${precoDoProduto3}`; 19 | } 20 | 21 | btnPreco.addEventListener('click', calcularPreco); -------------------------------------------------------------------------------- /Supermercado/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Supermercado 9 | 10 | 11 |
12 |

Supermercado

13 |
14 | 15 | 16 |
17 |
18 | 19 | 20 |
21 | 22 |
23 |

24 |

25 |
26 |
27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Supermercado/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: aliceblue; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | font-size: 3rem; 22 | border-bottom: 1px solid black; 23 | margin: 20px; 24 | } 25 | 26 | label { 27 | display: block; 28 | padding: 5px 0; 29 | } 30 | 31 | input[type="button"] { 32 | margin: 20px; 33 | padding: 5px; 34 | width: 10.5rem; 35 | } -------------------------------------------------------------------------------- /Tabuada/app.js: -------------------------------------------------------------------------------- 1 | const inputNumero = document.getElementById('inputNumero'); 2 | const btnCalcular = document.getElementById('btnCalcular'); 3 | const outTabuada = document.getElementById('outTabuada'); 4 | 5 | function mostrarTabuada() { 6 | 7 | let numero = Number(inputNumero.value); 8 | let tabuada = ''; 9 | 10 | if (inputNumero.value == '' || isNaN(numero)) { 11 | alert('Digite um número !'); 12 | inputNumero.value = ''; 13 | inputNumero.focus(); 14 | return; 15 | } 16 | 17 | for (let index = 1; index <= 10; index++) { 18 | tabuada += `${numero} x ${index} = ${numero * index}\n`; 19 | } 20 | 21 | outTabuada.textContent = `${tabuada}`; 22 | } 23 | 24 | btnCalcular.addEventListener('click', mostrarTabuada); -------------------------------------------------------------------------------- /Tabuada/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Tabuada 9 | 10 | 11 |
12 |

Tabuada

13 |
14 | 15 | 16 |
17 | 18 |
19 |

20 |         
21 |
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Tabuada/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | label { 21 | display: block; 22 | padding: 5px 0; 23 | } 24 | 25 | input[type="button"] { 26 | margin: 10px; 27 | padding: 5px; 28 | width: 12.7em; 29 | } 30 | 31 | pre { 32 | font-size: 15px; 33 | } -------------------------------------------------------------------------------- /UltimasNoticias/app.js: -------------------------------------------------------------------------------- 1 | const inputNoticia = document.getElementById('inputNoticia'); 2 | const btnAdicionar = document.getElementById('btnAdicionar'); 3 | const btnListarNoticia = document.getElementById('btnListarNoticia'); 4 | const outNumeroDeNoticias = document.getElementById('outNumeroDeNoticias'); 5 | const outNoticias = document.getElementById('outNoticias'); 6 | 7 | let noticias = []; 8 | 9 | function adicionarNoticias() { 10 | 11 | let noticiaCadastrada = inputNoticia.value; 12 | 13 | if (noticiaCadastrada == '') { 14 | alert('adicione allguma notícia!'); 15 | inputNoticia.focus(); 16 | return; 17 | } 18 | 19 | noticias.push(noticiaCadastrada); 20 | let lista = ''; 21 | 22 | for (let index = 0; index < noticias.length; index++) { 23 | lista = `Número de notícias cadastrada: ${index + 1}`; 24 | } 25 | // Alternativa de solução ao inves de utilizar o codigo a partir de let lista = ''; 26 | /* 27 | 28 | outNumeroDeNoticias.textContent = noticias.length; 29 | 30 | */ 31 | inputNoticia.value = ''; 32 | inputNoticia.focus(); 33 | 34 | outNumeroDeNoticias.textContent = lista; 35 | } 36 | 37 | btnAdicionar.addEventListener('click', adicionarNoticias); 38 | 39 | function listarNoticias() { 40 | 41 | let mostrarNoticias = Number(prompt('Quantas noticias você gostaria de ver ?')); 42 | let totalDeNoticias = noticias.length; 43 | 44 | if ((mostrarNoticias == 0) || isNaN(mostrarNoticias) || mostrarNoticias > totalDeNoticias) { 45 | alert('Escolha um número menor ou igual ao de notícias cadastradas!'); 46 | return; 47 | } 48 | 49 | let ultimasNoticias = `${mostrarNoticias} Última(s) notícia(s)\n--------------------- \n`; 50 | 51 | for (let i = totalDeNoticias - 1; i >= totalDeNoticias - mostrarNoticias; i--) { 52 | ultimasNoticias += `${i + 1}º) ${noticias[i]}\n`; 53 | } 54 | 55 | outNoticias.textContent = ultimasNoticias; 56 | } 57 | 58 | btnListarNoticia.addEventListener('click', listarNoticias); -------------------------------------------------------------------------------- /UltimasNoticias/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Últimas notícias 9 | 10 | 11 |
12 |

Últimas notícias

13 |
14 | 15 | 16 |
17 | 18 | 19 |
20 |

21 |
22 |
23 |

24 |         
25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /UltimasNoticias/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | border-bottom: 1px solid black; 22 | margin: 20px; 23 | } 24 | 25 | label { 26 | display: block; 27 | padding: 5px 0; 28 | } 29 | 30 | input[type="button"] { 31 | cursor: pointer; 32 | padding: 5px; 33 | margin: 10px; 34 | width: 12.7em; 35 | } 36 | -------------------------------------------------------------------------------- /VerificaVelocidade/app.js: -------------------------------------------------------------------------------- 1 | // Checa se a velocidade do condutor estava com mais de 20% de excesso de velocidade ou menos de 20%, e diz se recebe multa ou não, caso receba se é grave ou leve. 2 | 3 | const inputVelocidadePermitida = document.getElementById('inputVelocidadePermitida'); 4 | const inputVelocidadeDoVeiculo = document.getElementById('inputVelocidadeDoVeiculo'); 5 | const btnVelocidade = document.getElementById('btnVelocidade'); 6 | const outSituacao = document.getElementById('outSituacao'); 7 | 8 | function verificarVelocidade() { 9 | 10 | let velocidadePermitida = Number(inputVelocidadePermitida.value); 11 | let velocidadeDoVeiculo = Number(inputVelocidadeDoVeiculo.value); 12 | 13 | let velocidadeAcimaDoPermitido = (velocidadeDoVeiculo - velocidadePermitida); 14 | let vintePorCentoDoPermitido = (velocidadePermitida * 0.2); 15 | 16 | if ((inputVelocidadeDoVeiculo.value == '' || inputVelocidadePermitida.value == '') || (isNaN(velocidadePermitida) || isNaN(velocidadeDoVeiculo))) { 17 | alert('Digite uma velocidade válida !'); 18 | inputVelocidadeDoVeiculo.value =''; 19 | inputVelocidadePermitida.value = ''; 20 | inputVelocidadePermitida.focus(); 21 | return; 22 | } 23 | 24 | // se a velocidade for menor que o limite não paga multa 25 | if (velocidadeDoVeiculo < velocidadePermitida) { 26 | outSituacao.textContent = `Velocidade dentro do permitido. Sem multa !`; 27 | } else if (velocidadeAcimaDoPermitido >= vintePorCentoDoPermitido) { 28 | 29 | // se a velocidade for maior que 20% recebe multa grave 30 | outSituacao.textContent = `Você estava com a velocidade 20% acima do permitido. Multa Grave !`; 31 | } else { 32 | 33 | // se a velocidade excedida for menor que 20% recebe, multa leve 34 | outSituacao.textContent = `Você estava com menos de 20% de velocidade acima do permitido. Multa Leve !` 35 | } 36 | 37 | } 38 | 39 | btnVelocidade.addEventListener('click', verificarVelocidade); -------------------------------------------------------------------------------- /VerificaVelocidade/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Velocidade Limite 9 | 10 | 11 |
12 |

Verificador de Velocidade

13 |
14 | 15 | 16 |
17 |
18 | 19 | 20 |
21 | 22 |
23 |

24 |
25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /VerificaVelocidade/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0; 3 | padding: 0; 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | background-color: blanchedalmond; 9 | } 10 | 11 | .container { 12 | display: flex; 13 | align-items: center; 14 | justify-content: center; 15 | flex-direction: column; 16 | height: 100vh; 17 | width: auto; 18 | } 19 | 20 | h1 { 21 | margin: 20px; 22 | padding: 5px 0; 23 | border-bottom: 1px solid black; 24 | } 25 | 26 | label { 27 | display: block; 28 | padding: 5px 0; 29 | } 30 | 31 | input[type="button"] { 32 | margin: 20px; 33 | padding: 5px; 34 | width: 12.7em; 35 | } -------------------------------------------------------------------------------- /questoes.md: -------------------------------------------------------------------------------- 1 | # Enunciado de questões de Lógica de Programação e Algoritmos com Javascript. 2 | 3 | ### Capítulo 2 4 | 5 | **Execícios:** 6 | 7 | 1️⃣ - Locadora - Elaborar um programa para uma vídeo locadora, que leia o título e a duração de um filme em minutos. Exiba o título do filme e converta a duração para horas e minutos. 8 | 9 | 2️⃣ - Revenda de Veículos - Elaborar um programa para uma revenda de veículos. O programa de ler o modelo, o preço do veículo, deve apresentar o valor de entrada (50%) e o saldo em 12x. 10 | 11 | 3️⃣ - Restaurante - Elaborar um programa para um restaurante que exiba o preço por kg e o consumo (em gramas) de um cliente. 12 | 13 | 4️⃣ - Farmácia - Elabore um programa que leia a descrição e o preço de um medicamento e retorne o valor do produto na promoção. PROMOÇÃO --> Na compra de duas unidades de um mesmo medicamento, o cliente recebe como desconto os centavos do valor total. 14 | 15 | 5️⃣ - Lan House - Elabore um programa que le o valor de cada 15 minutos de uso de um computador e o tempo de uso por um cliente em minutos. Informe o valor a ser pago pelo cliente, sabendo que as frações extras de 15 minutos devem ser cobradas de forma integral. 16 | 17 | 6️⃣ - Supermercado - Para aumentar suas vendas no setor de higiene, cada etiqueta de produto deve exibir uma mensagem anunciando 50% de desconto (para cada item) na compra de três unidades do produto. Elabore um programa que leia a descrição e preço de um produto. Após, apresente as mensagens indicando a promoção. 18 | 19 | ### Capítulo 3 20 | 21 | **Execícios:** 22 | 23 | 7️⃣ - Peso Ideal - Construa um programa que calcule o peso ideal de uma pessoa a partir da formula: 22*Altura² (para Homens)*, e 21*Altura (para Mulheres)*. 24 | 25 | 8️⃣ - Fuso Horário - Elabore um programa que leia a hora no Brasil e informe a hora na França. Lembrando que o fuso da França é -5 em relação ao Brasil. 26 | 27 | 9️⃣ - Raiz Quadrada - Monte um programa que leia e calcule a raiz quadrada de um número, caso a raiz seja exata, informá-la, caso contrário, o programa de mostrar para o usuário 'Não há raiz exata para '. 28 | 29 | 🔟 - Caixa Eletrônico - Um Caixa Eletrônico só tem notas de 10, 50 e 100 reais disponíveis. Elaborar um programa que leia um valor de saque de um cliente, verifique sua validade (ou seja, se pode ser pago com as notas disponíveis) e informe o número mínimo de notas de 100, 50 e 10 necessárias para pagar o saque. 30 | 31 | 1️⃣:one: - Par ou ímpar - Elabore um programa que verifica se um número é par ou ímpar. Informe ou usuário se o número é par ou ímpar. 32 | 33 | 1️⃣:two: - Verifica Velocidade - Elaborar um programa que leia a velocidade permitida em uma estrada e a velocidade de um condutor. Se a velocidade for inferior ou igual á permitida, exiba 'Sem multa'. Se for maior que até 20% da permitida exiba 'Multa leve'. Se for maior 20% exiba 'Multa Grave'. 34 | 35 | 1️⃣:three: - Parquímetro - Elabore um programa para simular um parquímetro, o qual leia o valor de moeda depositado em um terminal de estacionamento rotativo. O programa deve informar o tempo de permanência do veiculo no local e o troco (se tiver), se o valor for menor que o tempo mínimo exiba a mensagem: 'valor insuficiente'. Cosiderar os valores a seguir: 36 | R$ 1,00 - 30 minutos 37 | R$ 1,75 - 60 minutos 38 | R$ 3,00 - 12 minutos 39 | 40 | 1️⃣:four: - Lados do Triângulo - Elabore um programa que leia três valores informados pelo usuário, e verifique se esses três números podem ou não formar um Triângulo. Caso possa formar um Triângulo, informar qual tipo: Isósceles, Equilátero ou Escaleno. 41 | 42 | ### Capítulo 4 43 | 44 | **Execícios.** 45 | 46 | :one::five: - Tabuada - Monte um programa que monstre a tabuada de um número. Exemplo: (n x 1)(n x 2) ... (n x 10). 47 | 48 | :one::six: - Números Decrescentes - Elaborar um programa que mostre todos os números em forma decrescente entre um número qualquer informado pelo usuário e o número 1. 49 | 50 | 51 | ### Capítulo 5 52 | 53 | **Execícios.** 54 | 55 | ### Capítulo 6 56 | 57 | **Execícios.** 58 | 59 | ### Capítulo 7 60 | 61 | **Execícios.** 62 | 63 | ### Capítulo 8 64 | 65 | **Execícios.** 66 | 67 | ### Capítulo 9 68 | 69 | **Execícios.** 70 | 71 | ### Capítulo 10 72 | 73 | **Execícios.** 74 | 75 | 76 | --------------------------------------------------------------------------------