forked from Midway91/HactoberFest2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram for making note.java
More file actions
51 lines (44 loc) · 1.58 KB
/
Program for making note.java
File metadata and controls
51 lines (44 loc) · 1.58 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
41
42
43
44
45
46
47
48
49
50
51
import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;
public class NoteTakingProgram {
private static ArrayList<String> notes = new ArrayList<>();
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (true) {
System.out.println("\nNote Taking Program Menu:");
System.out.println("1. Create a new note");
System.out.println("2. View existing notes");
System.out.println("3. Exit");
System.out.print("Enter your choice: ");
int choice = scanner.nextInt();
scanner.nextLine(); // Consume newline
switch (choice) {
case 1:
createNote(scanner);
break;
case 2:
viewNotes();
break;
case 3:
System.out.println("Exiting the program. Goodbye!");
scanner.close();
System.exit(0);
default:
System.out.println("Invalid choice. Please try again.");
}
}
}
private static void createNote(Scanner scanner) {
System.out.print("Enter your note: ");
String note = scanner.nextLine();
notes.add(note);
System.out.println("Note added successfully!");
}
private static void viewNotes() {
System.out.println("\nYour Notes:");
for (int i = 0; i < notes.size(); i++) {
System.out.println((i + 1) + ". " + notes.get(i));
}
}
}