-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx05_4.java
More file actions
33 lines (28 loc) · 955 Bytes
/
Ex05_4.java
File metadata and controls
33 lines (28 loc) · 955 Bytes
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
/* Criar um programa que leia dois vetores de inteiros de 10
posições, efetue a soma dos valores dos elementos de mesmo índice
dos dois vetores colocando o resultado em um terceiro vetor. Exiba
na tela o vetor resultante.
*
* Resolvido pelo aluno >> Gustavo Mota Macedo
*/
import java.util.Scanner;
public class Ex05_4 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] v1 = new int[10];
int[] v2 = new int[10];
int[] vSoma = new int[10];
for (int i = 0; i < v1.length; i++) {
System.out.println("Digite um numero para a posição " + (i + 1) + " do vetor 1");
v1[i] = sc.nextInt();
}
for (int i = 0; i < v2.length; i++) {
System.out.println("Digite um numero para a posição " + (i + 1) + " do vetor 2");
v2[i] = sc.nextInt();
}
for (int i = 0; i < v2.length; i++) {
vSoma[i] = v1[i] + v2[i];
System.out.println(vSoma[i]);
}
}
}