Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exercicios resolvidos do modulo 1 ao 3
- Loading branch information
0 parents
commit 22c96b3
Showing
51 changed files
with
2,055 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>Estudos-Java</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#Sun Mar 27 20:43:16 BRT 2011 | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.6 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.6 |
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Módulo 1 | ||
* Projeto e Construção de Sistemas | ||
* Professor: Alexandre Correa | ||
* | ||
* Implementado por Zeno Rocha | ||
* Em 17/03/2011 | ||
* | ||
* -------------------------------------------------------------------------------------------- | ||
* | ||
* Programa 2.5 | ||
* | ||
* Escreva um programa que imprima os números primos entre um limite inferior e um limite superior. | ||
* | ||
*/ | ||
|
||
package com.zenorocha.modulo1; | ||
|
||
import java.util.Scanner; | ||
|
||
public class DoisPontoCinco { | ||
private int limInferior; | ||
private int limSuperior; | ||
|
||
public DoisPontoCinco() { | ||
|
||
} | ||
|
||
public int getLimInferior() { | ||
return limInferior; | ||
} | ||
|
||
public void setLimInferior(int limInferior) { | ||
this.limInferior = limInferior; | ||
} | ||
|
||
public int getLimSuperior() { | ||
return limSuperior; | ||
} | ||
|
||
public void setLimSuperior(int limSuperior) { | ||
this.limSuperior = limSuperior; | ||
} | ||
|
||
public void defineNumeroPrimo() { | ||
for (int i = this.limInferior; i < this.limSuperior; i++) { | ||
//só falta descobrir como faz pra descobrir um numero primo | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
DoisPontoCinco objDoisPontoCinco = new DoisPontoCinco(); | ||
Scanner scanner = new Scanner(System.in); | ||
|
||
System.out.println("Entre com um valor para o limite inferior do intervalo"); | ||
objDoisPontoCinco.setLimInferior(scanner.nextInt()); | ||
|
||
System.out.println("Entre com um valor para o limite superior do intervalo"); | ||
objDoisPontoCinco.setLimSuperior(scanner.nextInt()); | ||
|
||
objDoisPontoCinco.defineNumeroPrimo(); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Módulo 1 | ||
* Projeto e Construção de Sistemas | ||
* Professor: Alexandre Correa | ||
* | ||
* Implementado por Zeno Rocha | ||
* Em 17/03/2011 | ||
* | ||
* -------------------------------------------------------------------------------------------- | ||
* | ||
* Programa 2.2 | ||
* | ||
* Escreva um programa que dado um intervalo de números inteiros definidos por limInferior | ||
* e limSuperior, imprima o quadrado e o cubo de cada um desses números. Se o | ||
* limiteSuperior for maior que 100 ou se o limiteSuperior for menor que limiteInferior uma | ||
* mensagem de erro deve ser exibida. Faça o programa com o comando for. Os valores para | ||
* limInferior e limSuperior devem ser entrados via argumentos do programa. | ||
* | ||
*/ | ||
|
||
package com.zenorocha.modulo1; | ||
|
||
import java.util.Scanner; | ||
|
||
public class DoisPontoDois { | ||
private int limInferior; | ||
private int limSuperior; | ||
|
||
public DoisPontoDois() { | ||
|
||
} | ||
|
||
public int getLimInferior() { | ||
return limInferior; | ||
} | ||
|
||
public void setLimInferior(int limInferior) { | ||
this.limInferior = limInferior; | ||
} | ||
|
||
public int getLimSuperior() { | ||
return limSuperior; | ||
} | ||
|
||
public void setLimSuperior(int limSuperior) { | ||
this.limSuperior = limSuperior; | ||
} | ||
|
||
public void doTheMagic() { | ||
System.out.println("Limite inferior ao quadrado: " + Math.pow(this.limInferior, 2)); | ||
System.out.println("Limite inferior ao cubo: " + Math.pow(this.limInferior, 3)); | ||
|
||
System.out.println("Limite superior ao quadrado: " + Math.pow(this.limSuperior, 2)); | ||
System.out.println("Limite superior ao cubo: " + Math.pow(this.limSuperior, 3)); | ||
|
||
if ((this.limInferior > 100) || (this.limSuperior < this.limInferior)) { | ||
System.out.println("Mensagem de erro"); | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
DoisPontoDois objDoisPontoDois = new DoisPontoDois(); | ||
Scanner scanner = new Scanner(System.in); | ||
|
||
for (int i = 0; i < 1; i++) { | ||
|
||
System.out.println("Entre com um valor para o limite inferior do intervalo"); | ||
objDoisPontoDois.setLimInferior(scanner.nextInt()); | ||
|
||
System.out.println("Entre com um valor para o limite superior do intervalo"); | ||
objDoisPontoDois.setLimSuperior(scanner.nextInt()); | ||
|
||
objDoisPontoDois.doTheMagic(); | ||
|
||
System.out.println("Deseja continuar? (0 - nao / 1 - sim)"); | ||
|
||
if (scanner.nextInt() == 0) | ||
i++; | ||
else | ||
i--; | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Módulo 1 | ||
* Projeto e Construção de Sistemas | ||
* Professor: Alexandre Correa | ||
* | ||
* Implementado por Zeno Rocha | ||
* Em 17/03/2011 | ||
* | ||
* -------------------------------------------------------------------------------------------- | ||
* | ||
* Programa 2.4 | ||
* | ||
* Faça uma versão do programa 2.2 com o comando do while. | ||
* | ||
*/ | ||
|
||
package com.zenorocha.modulo1; | ||
|
||
import java.util.Scanner; | ||
|
||
public class DoisPontoQuatro { | ||
private int limInferior; | ||
private int limSuperior; | ||
|
||
public DoisPontoQuatro() { | ||
|
||
} | ||
|
||
public int getLimInferior() { | ||
return limInferior; | ||
} | ||
|
||
public void setLimInferior(int limInferior) { | ||
this.limInferior = limInferior; | ||
} | ||
|
||
public int getLimSuperior() { | ||
return limSuperior; | ||
} | ||
|
||
public void setLimSuperior(int limSuperior) { | ||
this.limSuperior = limSuperior; | ||
} | ||
|
||
public void doTheMagic() { | ||
System.out.println("Limite inferior ao quadrado: " + Math.pow(this.limInferior, 2)); | ||
System.out.println("Limite inferior ao cubo: " + Math.pow(this.limInferior, 3)); | ||
|
||
System.out.println("Limite superior ao quadrado: " + Math.pow(this.limSuperior, 2)); | ||
System.out.println("Limite superior ao cubo: " + Math.pow(this.limSuperior, 3)); | ||
|
||
if ((this.limInferior > 100) || (this.limSuperior < this.limInferior)) { | ||
System.out.println("Mensagem de erro"); | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
DoisPontoQuatro objDoisPontoQuatro = new DoisPontoQuatro(); | ||
Scanner scanner = new Scanner(System.in); | ||
|
||
int resposta = 1; | ||
|
||
do { | ||
|
||
System.out.println("Entre com um valor para o limite inferior do intervalo"); | ||
objDoisPontoQuatro.setLimInferior(scanner.nextInt()); | ||
|
||
System.out.println("Entre com um valor para o limite superior do intervalo"); | ||
objDoisPontoQuatro.setLimSuperior(scanner.nextInt()); | ||
|
||
objDoisPontoQuatro.doTheMagic(); | ||
|
||
System.out.println("Deseja continuar? (0 - nao / 1 - sim)"); | ||
|
||
if (scanner.nextInt() == 0) | ||
break; | ||
else | ||
continue; | ||
} while (resposta == 1); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Módulo 1 | ||
* Projeto e Construção de Sistemas | ||
* Professor: Alexandre Correa | ||
* | ||
* Implementado por Zeno Rocha | ||
* Em 17/03/2011 | ||
* | ||
* -------------------------------------------------------------------------------------------- | ||
* | ||
* Programa 2.6 | ||
* | ||
* Escreva um programa que sorteie dez números inteiros e imprima os números sorteados, o | ||
* total de números pares sorteados, o total de números ímpares sorteados, o maior número | ||
* sorteado e o menor número sorteado. | ||
* | ||
*/ | ||
|
||
package com.zenorocha.modulo1; | ||
|
||
public class DoisPontoSeis { | ||
|
||
public DoisPontoSeis() { | ||
|
||
} | ||
|
||
public static void main(String[] args) { | ||
int vetor[] = new int[10]; | ||
int pares = 0; | ||
int impares = 0; | ||
int maior = 0; | ||
int menor = 101; | ||
|
||
for (int i = 0; i < 10; i++) { | ||
|
||
vetor[i] = (int)(Math.random() * 100); | ||
System.out.println("Foi sorteado o numero: " + vetor[i]); | ||
|
||
if ((vetor[i] % 2) == 0) | ||
pares++; | ||
else | ||
impares++; | ||
} | ||
|
||
System.out.println("Quantidade de números pares: " + pares); | ||
System.out.println("Quantidade de números ímpares: " + impares); | ||
|
||
for (int j = 0; j < vetor.length; j++) { | ||
if (vetor[j] > maior) { | ||
maior = vetor[j]; | ||
} | ||
|
||
if (vetor[j] < menor) { | ||
menor = vetor[j]; | ||
} | ||
} | ||
|
||
System.out.println("Maior número sorteado: " + maior); | ||
System.out.println("Menor número sorteado: " + menor); | ||
|
||
} | ||
} |
Oops, something went wrong.