-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiziMethod1.java
More file actions
42 lines (29 loc) · 1.12 KB
/
DiziMethod1.java
File metadata and controls
42 lines (29 loc) · 1.12 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
import java.util.*;
public class DiziMethod1 {
public static void main(String[] args) {
// Bir diziyi parametre alıp, dizinin tüm elemanlarını 3 katı ile değiştirdikten sonra diziyi geri döndüren bir mtd tasarlayın
Scanner inp = new Scanner(System.in);
System.out.println("Dizinin boyutunu giriniz");
int n = inp.nextInt();
int dizi[] = new int[n];
for (int i = 0; i < n; i++) {
System.out.println("Dizinin " + (i + 1 )+ "." + "Elemanını giriniz");
int g=inp.nextInt();
dizi[i] = g;}
System.out.println("Diziniz:");
for (int i = 0; i < n; i++) {
System.out.print(dizi[i]+" ");
}
System.out.println("\nMetota giden elemanların oluşturduğu yeni dizi: ");
method(dizi);
for (int i = 0; i < n; i++) {
System.out.print(dizi[i]+" ");
}
}
public static int[] method(int[] a) {
for (int i = 0; i < a.length; i++) {
a[i] = a[i] * 3;
}
return a;
}
}