This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import kotlin.math.* | |
| import java.math.BigDecimal | |
| import java.math.RoundingMode | |
| fun main() { | |
| var n = 9 | |
| for (nSqrt in 1..n) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Desafio cálculo de área | |
| // A fórmula para calcular a área de uma circunferência é: area = π . raio2. | |
| // Considerando para este problema que π = 3.14159: | |
| // - Efetue o cálculo da área, elevando o valor de raio ao quadrado e multiplicando por π. | |
| // Entrada | |
| // A entrada contém um valor de ponto flutuante (dupla precisão), no caso, a variável raio. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Desafio Cálculo de Imposto | |
| // Você terá o desafio de ler um valor com duas casas decimais, | |
| // equivalente ao salário de uma pessoa de Loli. Em seguida, | |
| // calcule e mostre o valor que esta pessoa deve pagar de Imposto de Renda, | |
| // segundo a tabela abaixo. | |
| // De 0.00 a 2000.00 -> Isento | |
| // De 2000.00 a 3000.00 -> 8% | |
| // De 3000.00 a 4500.00 -> 18% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.math.BigDecimal | |
| fun main() { | |
| //Extensions Functions(Funções Extendidas) têm por objetivo criar funções para uma classe específica, | |
| //SEM precisar de "herança" ou SEM utilizar algum design patterns(padrão de projeto) como por exemplo o "Decorator". | |
| val salarios = arrayOf( | |
| "2000".toBigDecimal(), | |
| "1500".toBigDecimal(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main() { | |
| val joao = Funcionario("João", 2000.0, "CLT") | |
| val pedro = Funcionario("Pedro", 1500.0, "PJ") | |
| val maria = Funcionario("Maria", 4000.0, "CLT") | |
| val repositorio = Repositorio<Funcionario>() | |
| repositorio.createClone(joao.nome, joao) | |
| repositorio.createClone(pedro.nome, pedro) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main() { | |
| val joao = Funcionario("João", 2000.0, "CLT") | |
| val pedro = Funcionario("Pedro", 1500.0, "PJ") | |
| val maria = Funcionario("Maria", 4000.0, "CLT") | |
| val repositorio = Repositorio<Funcionario>() | |
| //Cria os elementos do tipo "Funcionário" | |
| //dentro do "Banco de Dados"(Repositorio) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main() { | |
| val joao = Funcionario("João", 2000.0, "CLT") | |
| val pedro = Funcionario("Pedro", 1500.0, "PJ") | |
| val maria = Funcionario("Maria", 4000.0, "CLT") | |
| println("\n-------- LIST --------") | |
| val funcionarios = mutableListOf(joao, maria) | |
| funcionarios.forEach { println("\n${it}") } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main() { | |
| val pair: Pair<String, Double> = Pair("João", 1000.0) | |
| val map1 = mapOf(pair) | |
| //Consumer(consumidor) obtém de cada objeto na iteração | |
| //dentro da função lambda a "chave" e o respectivo "valor". | |
| map1.forEach { (k, v) -> println("Chave: $k | Valor: $v") } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main() { | |
| val joao = Funcionario("João", 2000.0, "CLT") | |
| val pedro = Funcionario("Pedro", 1500.0, "PJ") | |
| val maria = Funcionario("Maria", 4000.0, "CLT") | |
| val funcionarios1 = setOf(joao, pedro) | |
| val funcionarios2 = setOf(maria) | |
| val funcionarios3 = setOf(joao, pedro, maria) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main() { | |
| val joao = Funcionario("João", 2000.0, "CLT") | |
| val pedro = Funcionario("Pedro", 1500.0, "PJ") | |
| val maria = Funcionario("Maria", 4000.0, "CLT") | |
| val funcionarios = listOf(joao, pedro, maria) | |
| funcionarios.forEach { println("\n${it}") } | |
NewerOlder