0% found this document useful (0 votes)
7 views2 pages

Java To-Do List Application Code

The document is a Java program for a simple To-Do List application that allows users to add, view, and delete tasks. It uses an ArrayList to store tasks and a Scanner for user input. The program runs in a loop until the user chooses to exit, providing a menu for task management.

Uploaded by

chanchalameena8
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Java To-Do List Application Code

The document is a Java program for a simple To-Do List application that allows users to add, view, and delete tasks. It uses an ArrayList to store tasks and a Scanner for user input. The program runs in a loop until the user chooses to exit, providing a menu for task management.

Uploaded by

chanchalameena8
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import [Link].

ArrayList;
import [Link];

public class ToDoListApp {

public static void main(String[] args) {

ArrayList<String> tasks = new ArrayList<>();


Scanner sc = new Scanner([Link]);
int choice;

while (true) {
[Link]("\n===== TO-DO LIST MENU =====");
[Link]("1. Add Task");
[Link]("2. View Tasks");
[Link]("3. Delete Task");
[Link]("4. Exit");
[Link]("Enter your choice: ");

choice = [Link]();
[Link]();

switch (choice) {

case 1:
[Link]("Enter task name: ");
String task = [Link]();
[Link](task);
[Link](" Task added successfully!");
break;

case 2:
if ([Link]()) {
[Link]("No tasks available.");
} else {
[Link]("\n Your Tasks:");
for (int i = 0; i < [Link](); i++) {
[Link]((i + 1) + ". " + [Link](i));
}
}
break;

case 3:
if ([Link]()) {
[Link]("No tasks to delete.");
} else {
[Link]("Enter task number to delete: ");
int taskNumber = [Link]();
if (taskNumber > 0 && taskNumber <= [Link]()) {
[Link](taskNumber - 1);
[Link]("Task deleted successfully!");
} else {
[Link](“ Invalid task number.");
}
}
break;

case 4:
[Link]("Exiting To-Do List. Thank you!");
[Link]();
[Link](0);

default:
[Link](" Invalid choice. Please try again.");
}
}
}
}

You might also like