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 salarios = doubleArrayOf( 3000.0, 5000.0, 15000.0 ) | |
| // salarios.forEach{ println(it) } | |
| for (salario in salarios) { | |
| print("Salario: $salario, ") | |
| } | |
| println("\n\n-------- ITERAÇÃO --------\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
| fun main() { | |
| val salarios = doubleArrayOf( 3000.0, 5000.0, 15000.0 ) | |
| salarios.forEach{ println(it) } | |
| println("\n-------- ITERAÇÃO --------\n") | |
| salarios.forEachIndexed { index, salario -> | |
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 salarios = DoubleArray( 3 ) | |
| salarios[0] = 1000.0 | |
| salarios[1] = 3000.0 | |
| salarios[2] = 5000.0 | |
| salarios.forEach{ println(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 estadosArrayOf = arrayOf("Paraná", "Ceará", "Mato Grosso", "Alagoas", "Maranhão") | |
| for (estados in estadosArrayOf) { | |
| println(estados) | |
| } | |
| println("\n-------- ORDENAÇÃO --------\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
| fun main() { | |
| val capitaisArrayString = Array( 5) {""} | |
| capitaisArrayString[0] = "São Paulo" | |
| capitaisArrayString[1] = "Recife" | |
| capitaisArrayString[2] = "Rio de Janeiro" | |
| capitaisArrayString[3] = "Curitiba" | |
| capitaisArrayString[4] = "Manaus" | |
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() { | |
| // Diferente do "arrayListOf" o Array de String abaixo recebe o tipo | |
| // e exige que seja informada a quantidade de elementos que será "fixa"(quantidade), | |
| // sendo ("3" posições no exemplo abaixo) e lembrando que conta-se [0, 1, 2] elementos; | |
| // Também é necessário fornecer uma inicialização, no caso uma string vazia: {""} | |
| // val letrasArrayString = Array<String>( 3) {""} | |
| // Ainda no mesmo exemplo acima e repetido abaixo, é possível ocultar o tipo "Array<String>" pois |
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(args: Array<String>) { | |
| val nomes = arrayListOf("Renata", "Bernardo", "Willian", "Andreia", "Caio") | |
| val ordenados = nomes.sortedBy { it } | |
| println(ordenados) | |
| } |
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 de potenciação | |
| // Você terá o desafio de escrever um programa que leia um valor inteiro N (1 =< N <= 1000). | |
| // Este N é a quantidade de linhas de saída que serão apresentadas na execução do programa. | |
| // Entrada | |
| // O arquivo de entrada contém um número inteiro positivo N. | |
| // Saída | |
| // Imprima a saída conforme o exemplo fornecido. |
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 rangeTo() | |
| // Leia um valor inteiro X (1 <= X <= 1000). Em seguida mostre os ímpares de 1 até X, | |
| //um valor por linha, inclusive o X, se for o caso. | |
| // Entrada | |
| // O arquivo de entrada contém 1 valor inteiro qualquer. | |
| // Saída | |
| // Imprima todos os valores ímpares de 1 até X, inclusive X, se for o caso. |
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 eitler = Analista( "Eitler Pereira", "1234567899", 1000.01) | |
| ImprimeRelatorioFuncionario.imprime(eitler) | |
| val joao = Gerente( "João Silva", "9876543211", 2000.04, "123") | |
| ImprimeRelatorioFuncionario.imprime(joao) | |
| ValidaAutentica().autentica(joao) | |
| val maria = Cliente( "Maria Silva", "4321987655", ClienteTipo.PESSOA_FISICA,"321") |