-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
87 lines (69 loc) · 1.84 KB
/
Main.java
File metadata and controls
87 lines (69 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package br.com.teste.projeto.modulo;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
//Exercicio1
int [][] m1 = {
{3,4,5},
{7,8,4},
{3,9,2},
};
int [][] m2 = {
{6,6,3},
{4,8,4},
{1,9,2},
};
int soma [][]= new int [3][3];
System.out.println("Resultado: ");
for(int l=0; l<3;l++) {
for(int c=0; c<3; c++){
soma[l][c] = m1[l][c] + m2[l][c];
System.out.print(" | " + soma[l][c] );
}
System.out.println();
}
//Exercicio2
String [][] dados = {
{"user0", "123"},{"user1","456"},{"user2","789"},
{"user3","101"},{"user4", "111"},{"user5","222"},
};
boolean encontrado=false;
System.out.println("Digite o login: ");
String login = scan.nextLine();
System.out.println("Digite a senha: ");
String senha = scan.nextLine();
for(int l=0; l<dados.length;l++) {
if(login.equals(dados[l][0]) && senha.equals(dados[l][1])) {
encontrado = true;
break;
}
}
if(encontrado) {
System.out.println("Acesso permitido!");
}else {
System.out.println("Acesso negado!");
}
//Exercicio3
String [][] matriz = new String [2][2];
String [][] reverso = new String [2][2];
for(int l=0; l < 2;l++) {
for(int c=0; c < 2; c++) {
System.out.println("Digite um valor: ");
matriz[l][c]=scan.nextLine();
}
}
for(int l=0; l < 2;l++) {
for(int c=0; c < 2; c++) {
reverso[l][c]=matriz[c][l];
}
}
for(String[]linha : reverso) {
for(String coluna : linha) {
System.out.print(coluna + " | ");
}
System.out.println();
}
scan.close();
}
}