diff --git a/java/src/dev/andreijiroh/studentops/projects/finaPT.java b/java/src/dev/andreijiroh/studentops/projects/finaPT.java deleted file mode 100644 index e99b675..0000000 --- a/java/src/dev/andreijiroh/studentops/projects/finaPT.java +++ /dev/null @@ -1,32 +0,0 @@ -package dev.andreijiroh.studentops.projects; -// import the entire base modules -import module java.base; - -/** - * Computer Programming 1 - 07 Performance Task 1 - * @author Andrei Jiroh Eugenio Halili (STI College Meycauayan) - */ -public class finaPT { - public static void main(String[] args) { - // Output - System.out.println("Well hello there!"); - - // Input + loops - while (true) { - System.out.print("What's cooking for today? "); - String dailyLog = scanner.nextLine().trim(); - Scanner scanner = new Scanner(System.in); - if (dailyLog.isEmpty()) { - System.out.println("You forgot to log something"); - } else { - break; - } - } - - // Array + conditionals (switches) - string[] categories = {"School", "Work", "Personal", "Others"}; - println("What category is this?") - - scanner.close(); - } -} diff --git a/java/src/dev/andreijiroh/studentops/projects/finalPT.java b/java/src/dev/andreijiroh/studentops/projects/finalPT.java new file mode 100644 index 0000000..87c67ae --- /dev/null +++ b/java/src/dev/andreijiroh/studentops/projects/finalPT.java @@ -0,0 +1,68 @@ +package dev.andreijiroh.studentops.projects; +import module java.base; // `import module` as preview in Java 23, standard in Java 25 +import java.util.Scanner; + +/** + * Computer Programming 1 - 07 Performance Task 1 + * @author Andrei Jiroh Eugenio Halili (STI College Meycauayan) + */ +public class finalPT { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + // Output + System.out.println("Well hello there!"); + + // Input + loops + String dailyLog; + while (true) { + System.out.print("What's cooking for today? (summarize what you did in a few sentences) "); + dailyLog = scanner.nextLine().trim(); + if (dailyLog.isEmpty()) { + System.out.println("You forgot to log something"); + } else { + break; + } + } + + // Array + conditionals (switches) + String[] categories = {"School", "Work", "Personal", "Others"}; + String category = null; + String cat_prompt = """ + Available categories: + + [1] School + [2] Work + [3] Personal + [4] Others + + Please select the category in question for this entry: """; + while (true) { + System.out.print(cat_prompt); + int category_number = scanner.nextInt(); + switch (category_number) { + case 1: + category = categories[0]; + break; + case 2: + category = categories[1]; + case 3: + category = categories[2]; + case 4: + category = categories[3]; + default: + System.out.println("Please select the number"); + }; + break; + }; + scanner.close(); + + Calendar today = Calendar.getInstance(); + int year = today.get(Calendar.YEAR); + int month = today.get(Calendar.MONTH) + 1; + int day = today.get(Calendar.DAY_OF_MONTH); + System.out.println("Date: " + year + "-" + month + "-" + day); + System.out.println("Journal entry: " + dailyLog); + System.out.println("Category: " + category); + } +} diff --git a/java/src/dev/andreijiroh/studentops/projects/inputAndOutput.java b/java/src/dev/andreijiroh/studentops/projects/inputAndOutput.java index 3356bed..b565f32 100644 --- a/java/src/dev/andreijiroh/studentops/projects/inputAndOutput.java +++ b/java/src/dev/andreijiroh/studentops/projects/inputAndOutput.java @@ -20,7 +20,7 @@ public class inputAndOutput { String studentType; int id; int year = today.get(Calendar.YEAR); - int month = today.get(Calendar.MONTH) + 1; + int month = today.get(Calendar.MONTH); int day = today.get(Calendar.DAY_OF_MONTH); String subject; String activitySummary;