-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExer04.java
More file actions
41 lines (26 loc) · 853 Bytes
/
Exer04.java
File metadata and controls
41 lines (26 loc) · 853 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
34
35
36
37
38
39
package com.laiane.cursojava.aula19;
import java.text.DecimalFormat;
import java.util.Scanner;
public class Exer04 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int[] vetorA = new int[15];
double[] vetorB = new double[vetorA.length];
for (int i=0; i<vetorA.length; i++){
System.out.println("Entre com o valor da posição: " + i);
vetorA[i] = scan.nextInt();
vetorB[i] = Math.sqrt(vetorA[i]);
}
System.out.println("Vetor A = ");
for (int i=0; i<vetorA.length; i++){
System.out.println(vetorA[i] + "");
}
System.out.println();
DecimalFormat df = new DecimalFormat("###,###.###");
System.out.println("Vetor B = ");
for (int i=0; i<vetorB.length; i++){
System.out.println(df.format(vetorB[i]) + " ");
}
System.out.println();
}
}