File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed
Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ package ToDoList ;
2+
3+ import java .util .*;
4+
5+ public class ToDoList {
6+
7+ public static void main (String [] args ) {
8+ Scanner sc = new Scanner (System .in );
9+ ArrayList <String > todolist = new ArrayList <>();
10+ Random random = new Random ();
11+ while (true ) {
12+ System .out .println ("1. add task " );
13+ System .out .println ("2. view tasks" );
14+ System .out .println ("3. exit" );
15+ System .out .println ("Enter your choice: " );
16+
17+ int options = sc .nextInt ();
18+ sc .nextLine ();
19+
20+ switch (options ){
21+ case 1 :
22+ addtask (sc ,todolist );
23+ break ;
24+ case 2 :
25+ viewtasks (todolist );
26+ break ;
27+ case 3 :
28+ System .out .println ("Exiting the Program. GOODBYE!!!" );
29+ System .exit (0 );
30+ default :
31+ System .out .println ("Invalid Choice. Enter the valid option" );
32+
33+
34+ }
35+ }
36+ }
37+ private static void addtask (Scanner sc , ArrayList <String > todolist ){
38+ System .out .println ("enter the task " );
39+ todolist .add (sc .nextLine ());
40+ System .out .println ("Task Added!!\n " );
41+ }
42+
43+ private static void viewtasks (ArrayList <String > todolist ) {
44+ if (todolist .isEmpty ()){
45+ System .out .println ("the To-Do-List is Empty !!" );
46+ }
47+ else
48+ {
49+ System .out .println ("To-Do-List : \n " + String .join (".\n " ,todolist )+".\n " );
50+ }
51+ }
52+
53+
54+ }
You can’t perform that action at this time.
0 commit comments