Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed MenorOuMaiorC.java
Empty file.
Empty file removed MenuLanchonete.java
Empty file.
Empty file removed ParImparPositivoNegativo.java
Empty file.
Empty file removed ReajusteSalario.java
Empty file.
41 changes: 41 additions & 0 deletions tresMatriz.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package matriz;

public class tresMatriz {

public static void main(String[] args) {
int matrizInt[][] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int tamanhoMatriz = matrizInt.length;
int somaDiagonalPrincipal = 0;
int somaDiagonalSecundaria = 0;

System.out.println("Todos os elementos da Diagonal Principal: ");
for (int i = 0; i < matrizInt.length; i++) {
System.out.print(matrizInt[i][i] +" ");
}
System.out.println();


System.out.println("Todos os elementos da Diagonal Secundária: ");
for (int i = 0; i < tamanhoMatriz; i++) {
System.out.print(matrizInt[i][tamanhoMatriz - 1 - i] + " ");
}
System.out.println();

for (int i = 0; i < tamanhoMatriz; i++) {
somaDiagonalPrincipal += matrizInt[i][i];
}

for (int i = 0; i < tamanhoMatriz; i++) {
somaDiagonalSecundaria += matrizInt[i][tamanhoMatriz - 1 - i];
}



System.out.println("Soma dos os elementos da Diagonal Primária: ");
System.out.println(somaDiagonalPrincipal);
System.out.println("Soma dos os elementos da Diagonal Secundária: ");
System.out.println(somaDiagonalSecundaria);


}
}
48 changes: 48 additions & 0 deletions vetorNumInteiros.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package vetores;

public class vetorNumInteiros {

public static void main(String[] args) {
int[] numeros = {5, 8, 9, 6, 7, 3, 4, 1, 2, 10};
int soma = 0;
float media = 0;

System.out.println("Lista completa: ");
for (int i : numeros) {
System.out.print(i + " ");
}
System.out.println(" ");


System.out.println("Números ímpares: ");
for (int i : numeros) {
if (i % 2 != 0) {
System.out.print(i + " ");
}
}
System.out.println(" ");


System.out.println("Números pares: ");
for (int i : numeros) {
if (i % 2 == 0) {
System.out.print(i + " ");
}
}
System.out.println(" ");

System.out.println("Soma de todos os números: ");
for (int i : numeros) {
soma += i;
}
System.out.println(soma + " ");

System.out.println("A média de todos os números: ");
for (int i : numeros) {
media = (i) / 2;
}
System.out.println(media + " ");
}


}