-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestion1.java
More file actions
29 lines (24 loc) · 889 Bytes
/
Question1.java
File metadata and controls
29 lines (24 loc) · 889 Bytes
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
package Examples.demos;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Question1 {
public static void main(String[] args) {
List<String> todoList = new ArrayList<>();
String userInput = "";
Scanner scanner = new Scanner(System.in);
System.out.println("You can type \"Print\" to view your current list, or \"Exit\" to close the application.");
while (!userInput.equals("Exit")) {
System.out.println("Please enter an item to add to your list.");
userInput = scanner.nextLine();
todoList.add(userInput);
if (userInput.equals("Print")) {
for (String value:
todoList) {
System.out.println(value);
}
}
}
System.out.println("Thank you, goodbye!");
}
}