Skip to content

Commit a560ae4

Browse files
committed
push for exercises
1 parent 686f622 commit a560ae4

5 files changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import java.util.ArrayList;
2+
3+
public class arraylistpractice {
4+
static public void main(String[] args) {
5+
public static int sumEven(ArrayList<Integer> arr) {
6+
int total = 0;
7+
for (int integer : arr) {
8+
if (integer % 2 == 0) {
9+
total += integer;
10+
}
11+
}
12+
return total;
13+
}
14+
15+
16+
}
17+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public class arraypractice {
2+
public static void main(String[] args) {
3+
int[] integerArray = {1, 1, 2, 3, 5, 8};
4+
for (int i = 0; i < integerArray.length; i++) {
5+
if (integerArray[i] % 2 != 0) {
6+
System.out.println(integerArray[i]);
7+
}
8+
}
9+
}
10+
}
11+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import java.util.Arrays;
2+
3+
public class foxarray {
4+
public static void main(String[] args) {
5+
String str = "I would not, could not, in a box. I would not, could not with a fox. I will not eat them in a house. I will not eat them with a mouse.";
6+
String[] words = str.split(" ");
7+
System.out.println(Arrays.toString(words));
8+
String[] sentences = str.split("\\.");
9+
System.out.println(Arrays.toString(sentences));
10+
}
11+
}
12+
13+
14+
15+
16+
17+
18+
//public class arraypractice {
19+
// public static void main(String[] args) {
20+
// int[] integerArray = {1, 1, 2, 3, 5, 8};
21+
// for (int i = 0; i < integerArray.length; i++) {
22+
// if (integerArray[i] % 2 != 0) {
23+
// System.out.println(integerArray[i]);
24+
// }
25+
// }
26+
// }
27+
//}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.launchcode;
2+
import radius.Int;
3+
4+
import java.util.Scanner;
5+
6+
public class AreaValidation {
7+
public static void main(String[] args) {
8+
double radius;
9+
Scanner input;
10+
input = new Scanner(System.in);
11+
12+
System.out.println("Enter Radius now!: ");
13+
radius = input.nextDouble();
14+
double area = circle.getArea(radius);
15+
16+
if (radius <= 0) {
17+
System.out.println("Area must be a positive number");
18+
input.close();
19+
} else if (input.hasNextDouble()){
20+
System.out.println("Radius must be a number");
21+
input.close();
22+
} else {
23+
System.out.println("The area of a circle of radius " + radius + " is: " + area);
24+
input.close();
25+
}
26+
}
27+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package radius;
2+
3+
public class Int {
4+
}

0 commit comments

Comments
 (0)