Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelectric_potential.java
More file actions
Latest commit
62 lines (52 loc) · 2.4 KB
/
Copy pathelectric_potential.java
File metadata and controls
62 lines (52 loc) · 2.4 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
/**---------------------------------------------------
* Akdeniz University CSE122 Physics II Homework
* @author: Yahya Efe Kuruçay
* @since: 26.05.2024
* Description: Homework
* Score: ?
* Website: https://efekurucay.com
*---------------------------------------------------*/
/***
* ███████ ███████ ███████ | ███████ ███████ ███████
* ██ ██ ██ | ██ ██ ██
* █████ █████ █████ | █████ █████ █████
* ██ ██ ██ | ██ ██ ██
* ███████ ██ ███████ | ███████ ██ ███████
*
*
*/
publicclasselectric_potential {
publicstaticvoidmain(String[] args) {
// Öğrenci numarası ve yük hesaplamaları
intstudentId = 20808005; // Öğrenci numaranızı buraya girin
doublecharge = (studentId % 10) * 1e-9; // nC cinsinden yük
doubleepsilon_0 = 8.85e-12; // C^2/(N·m^2)
// Matris boyutu ve hücre uzunluğu
intmatrixSize = 10;
doublecellLength = 0.1; // metre
// Potansiyel matrisi oluşturma
double[][] potentialMatrix = newdouble[matrixSize][matrixSize];
// Potansiyel hesaplama fonksiyonu
for (inti = 0; i < matrixSize; i++) {
for (intj = 0; j < matrixSize; j++) {
doublex = i * cellLength;
doubley = j * cellLength;
potentialMatrix[i][j] = calculatePotential(charge, x, y, epsilon_0);
}
}
// Potansiyel matrisini yazdırma
for (inti = 0; i < matrixSize; i++) {
for (intj = 0; j < matrixSize; j++) {
System.out.printf("%.2e ", potentialMatrix[i][j]);
}
System.out.println();
}
}
publicstaticdoublecalculatePotential(doubleq, doublex, doubley, doubleepsilon_0) {
doubler = Math.sqrt(x * x + y * y);
if (r == 0) {
returnDouble.POSITIVE_INFINITY; // Sonsuz potansiyel
}
returnq / (4 * Math.PI * epsilon_0 * r);
}
}