Skip to content

Commit

Permalink
Exercicios resolvidos do modulo 1 ao 3
Browse files Browse the repository at this point in the history
  • Loading branch information
zenorocha committed Mar 28, 2011
0 parents commit 22c96b3
Show file tree
Hide file tree
Showing 51 changed files with 2,055 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .classpath
@@ -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>
17 changes: 17 additions & 0 deletions .project
@@ -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>
12 changes: 12 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
@@ -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 added README
Empty file.
Binary file added bin/com/zenorocha/modulo1/DoisPontoCinco.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo1/DoisPontoDois.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo1/DoisPontoQuatro.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo1/DoisPontoSeis.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo1/DoisPontoTres.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo1/DoisPontoUm.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo1/UmPontoCinco.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo1/UmPontoDois.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo1/UmPontoQuatro.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo1/UmPontoTres.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo1/UmPontoUm.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo2/TresPontoDois.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo2/TresPontoQuatro.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo2/TresPontoTres.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo2/TresPontoUm.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo3/Comprimento_01.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo3/Comprimento_02.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo3/Empregado.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo3/TesteComprimento.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added bin/com/zenorocha/modulo4/EmpregadoHorista.class
Binary file not shown.
Binary file added bin/com/zenorocha/modulo4/FolhaPagamento.class
Binary file not shown.
63 changes: 63 additions & 0 deletions src/com/zenorocha/modulo1/DoisPontoCinco.java
@@ -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();
}
}
83 changes: 83 additions & 0 deletions src/com/zenorocha/modulo1/DoisPontoDois.java
@@ -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--;
}
}
}
81 changes: 81 additions & 0 deletions src/com/zenorocha/modulo1/DoisPontoQuatro.java
@@ -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);
}
}
62 changes: 62 additions & 0 deletions src/com/zenorocha/modulo1/DoisPontoSeis.java
@@ -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);

}
}

0 comments on commit 22c96b3

Please sign in to comment.