-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelloWorld.java
More file actions
46 lines (34 loc) · 1.05 KB
/
HelloWorld.java
File metadata and controls
46 lines (34 loc) · 1.05 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
//Beginner Java Projects
//1. Hello World
//2. Capitalize the first letter of an input
//3. Pick the first even number in the array
import java.util.Scanner;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
public class HelloWorld {
public static void main(String[] args){
System.out.println("Hello World");
//capitalize();
System.out.println(returnFirstEven());
}
public static void capitalize(){
Scanner reader = new Scanner(System.in);
System.out.println("Enter a word");
String word = reader.next();
String cap = word.substring(0,1).toUpperCase() + word.substring(1);
System.out.println(cap);
reader.close();
}
public static List<Integer> returnFirstEven(){
Scanner input = new Scanner(System.in).useDelimiter("\\s*\\s*");
System.out.println("Enter an array of numbers");
List<Integer> numbers = new ArrayList<Integer>();
while (input.hasNextInt()){
numbers.add(input.nextInt());
}
System.out.println("You entered the following array" + numbers);
input.close();
return numbers;
}
}