-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaula16.java
54 lines (48 loc) · 1.59 KB
/
aula16.java
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
//import java.util.Scanner;
public class aula16 {
/*
public static void main(String[]args){
Scanner scanner = new Scanner(System.in);
System.out.println("Digite a sua idade em anos: ");
int anos = scanner.nextInt();
System.out.println("Digite a quantidade de meses desde o seu ultimo aniversario: ");
int meses = scanner.nextInt();
System.out.println("Digite a quantidade de dias desde o ultimo mes de aniversario: ");
int dias = scanner.nextInt();
int idadeEmDias = anos * 365 + meses * 30 + dias;
System.out.println("Sua idade em dias e:" + idadeEmDias);
}
*/
/*
public static void main(String[]args){
Scanner scanner = new Scanner(System.in);
System.out.print("Digite n1: ");
int n1 = scanner.nextInt();
System.out.print("Digite n2: ");
int n2 = scanner.nextInt();
System.out.print("Digite n3: ");
int n3 = scanner.nextInt();
double res = (n1 + n2 + n3) / 3.0;
System.out.print("A medeia e: " + res);
}
*/
public static void main(String[] args)
{
// declares an Array of integers.
int[] arr;
// allocating memory for 5 integers.
arr = new int[5];
// initialize the first elements of the array
arr[0] = 10;
// initialize the second elements of the array
arr[1] = 20;
// so on...
arr[2] = 30;
arr[3] = 40;
arr[4] = 50;
// accessing the elements of the specified array
for (int i = 0; i < arr.length; i++)
System.out.println("Element at index " + i
+ " : " + arr[i]);
}
}