Skip to content

Commit 995463f

Browse files
committed
powtorka petle
1 parent b2efaa4 commit 995463f

File tree

7 files changed

+151
-93
lines changed

7 files changed

+151
-93
lines changed

.idea/workspace.xml

Lines changed: 96 additions & 85 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
1.65 KB
Binary file not shown.

src/jp/JP19.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public static void main(String[] args) {
88
Scanner sc = new Scanner(System.in);
99
System.out.println("Podaj amplitude");
1010
int amplituda = sc.nextInt();
11-
for (double i = 0; i < 5; i += 0.1) {
11+
for (double i = 0; i < 6; i += 0.1) {
1212
int ilosc = (int) (Math.sin(i) * amplituda);
1313
if (ilosc >= 0) {
1414
for (int j = 0; j < ilosc; j++) {

src/start/Loop.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,14 @@ public static void main(String[] args) {
99

1010
int key = -1;
1111
while (key != 0) {
12-
13-
1412
System.out.println("Co chcesz zrobić :\n (1) Zadanie1 \n (2) Zadanie2 \n (3) Zadanie3 \n (0) Wyjście");
15-
1613
key = scanner.nextInt();
1714

1815
switch (key) {
1916
case 1:
2017
System.out.println("Rozwiązanie zadania 1");
2118
break;
2219
case 2:
23-
2420
System.out.println("Rozwiązanie zadania 2");
2521
break;
2622
case 3:
@@ -32,9 +28,6 @@ public static void main(String[] args) {
3228
default:
3329
System.out.println("Zły wybór!");
3430
}
35-
36-
3731
}
38-
3932
}
4033
}

src/start/Repetition.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package start;
2+
3+
import java.util.Scanner;
4+
5+
public class Repetition {
6+
public static void main(String[] args) {
7+
//1. instrukcje warunkowe
8+
//if
9+
//switch case
10+
//2.Pętle
11+
//for
12+
//for each
13+
//while
14+
//do while
15+
//3.Tablice
16+
17+
//deklaracje tablicy liczb calkowitych o wuymiarze 10 elementow
18+
19+
int numtab[] = new int[10];
20+
// uzytkownik w petli przypisal wartosci do wszystkich komorek
21+
Scanner sc = new Scanner(System.in);
22+
for (int i = 0; i < numtab.length; i++) {
23+
System.out.println("Podaj " + i + " element tablicy");
24+
numtab[i] = sc.nextInt();
25+
}
26+
for (int element : numtab) {
27+
System.out.print(element + " ");
28+
}
29+
// w pętli while wypisz tylko parzyste wartosci z tablicy
30+
System.out.print("\nElementy parzyste ");
31+
int i = 0;
32+
while (i < numtab.length) {
33+
if ((numtab[i] % 2 == 0) && numtab[i] != 0) {
34+
System.out.print(numtab[i] + " ");
35+
}
36+
i++;
37+
}
38+
//oblicz wartosc maksymalna w tablicy
39+
int maxVal = numtab[0];
40+
for (int element : numtab) {
41+
if (element > maxVal) {
42+
maxVal = element;
43+
}
44+
//maxVal = element> maxVal ? element : maxVal; //lub to
45+
}
46+
System.out.println("\nMAX VAL: " + maxVal);
47+
//oblicz srednia artmetryczna wszystkich elementow tablicy
48+
int sum = 0;
49+
for (int element : numtab) {
50+
sum = sum + element;
51+
}
52+
System.out.println("AVG: " + (double)sum/numtab.length);
53+
}
54+
}

0 commit comments

Comments
 (0)