From 7cb23e26109fbca25bf0848cd6943dd2296883a0 Mon Sep 17 00:00:00 2001 From: Krish Date: Tue, 15 Jul 2025 20:14:15 +0530 Subject: [PATCH 1/5] Solution of Q2 Commited By Krish Miyani --- FLow_Q2_Krish .java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 FLow_Q2_Krish .java diff --git a/FLow_Q2_Krish .java b/FLow_Q2_Krish .java new file mode 100644 index 000000000..976b0800a --- /dev/null +++ b/FLow_Q2_Krish .java @@ -0,0 +1,18 @@ +// Take two numbers and print the sum of both. +import java.util.Scanner; +class FLow_Q2_Krish +{ + public static void main(String[] args) + { + Scanner sc = new Scanner(System.in); + System.out.print("Enter first number: "); + int num1 = sc.nextInt(); + System.out.print("Enter second number: "); + int num2 = sc.nextInt(); + + int sum = num1 + num2; + System.out.println("The sum of " + num1 + " and " + num2 + " is: " + sum); + // Close the scanner to prevent resource leaks + sc.close(); + } +} From abd5acfb1aace17f0f320b097153a3f87debd270 Mon Sep 17 00:00:00 2001 From: Krish Date: Wed, 16 Jul 2025 20:43:07 +0530 Subject: [PATCH 2/5] Added Solution for Question 3 --- FLOW_Q3_Krish.java | 18 ++++++++++++++++++ lectures/20-trees/code/AVL/.project | 4 ++-- lectures/20-trees/code/Questions/.project | 4 ++-- 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 FLOW_Q3_Krish.java diff --git a/FLOW_Q3_Krish.java b/FLOW_Q3_Krish.java new file mode 100644 index 000000000..bdeef51cc --- /dev/null +++ b/FLOW_Q3_Krish.java @@ -0,0 +1,18 @@ +// Take a number as input and print the multiplication table for it. +class FLOW_Q3_Krish +{ + public static void main(String[] args) + { + java.util.Scanner sc = new java.util.Scanner(System.in); + System.out.print("Enter a number to print its multiplication table: "); + int num = sc.nextInt(); + + System.out.println("Multiplication table for " + num + ":"); + for (int i = 1; i <= 10; i++) { + System.out.println(num + " x " + i + " = " + (num * i)); + } + + // Close the scanner to prevent resource leaks + sc.close(); + } +} diff --git a/lectures/20-trees/code/AVL/.project b/lectures/20-trees/code/AVL/.project index a2380fe36..b545323bf 100644 --- a/lectures/20-trees/code/AVL/.project +++ b/lectures/20-trees/code/AVL/.project @@ -22,12 +22,12 @@ - 1679078569810 + 1752678436405 30 org.eclipse.core.resources.regexFilterMatcher - node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ diff --git a/lectures/20-trees/code/Questions/.project b/lectures/20-trees/code/Questions/.project index a2380fe36..a73354206 100644 --- a/lectures/20-trees/code/Questions/.project +++ b/lectures/20-trees/code/Questions/.project @@ -22,12 +22,12 @@ - 1679078569810 + 1752678436432 30 org.eclipse.core.resources.regexFilterMatcher - node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ From 04c39f7c4ecb1eddffb5ae194e0d61441375773d Mon Sep 17 00:00:00 2001 From: Krish Date: Wed, 16 Jul 2025 20:46:44 +0530 Subject: [PATCH 3/5] Added Solustion of Q3 By Keish Miyani --- FLOW_Q3_Krish.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FLOW_Q3_Krish.java b/FLOW_Q3_Krish.java index bdeef51cc..cc3bbe5c9 100644 --- a/FLOW_Q3_Krish.java +++ b/FLOW_Q3_Krish.java @@ -11,7 +11,7 @@ public static void main(String[] args) for (int i = 1; i <= 10; i++) { System.out.println(num + " x " + i + " = " + (num * i)); } - + // // Close the scanner to prevent resource leaks sc.close(); } From f1ef056d3968ee6dca21102d611a81d9ac21508d Mon Sep 17 00:00:00 2001 From: Krish Date: Wed, 16 Jul 2025 20:52:53 +0530 Subject: [PATCH 4/5] Sloustion-of-Q4-Flow --- FLOW_Q4_Krish.java | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 FLOW_Q4_Krish.java diff --git a/FLOW_Q4_Krish.java b/FLOW_Q4_Krish.java new file mode 100644 index 000000000..42806b121 --- /dev/null +++ b/FLOW_Q4_Krish.java @@ -0,0 +1,30 @@ +// Take 2 numbers as inputs and find their HCF and LCM. +public class FLOW_Q4_Krish +{ + public static void main(String[] args) + { + java.util.Scanner sc = new java.util.Scanner(System.in); + System.out.print("Enter first number: "); + int num1 = sc.nextInt(); + System.out.print("Enter second number: "); + int num2 = sc.nextInt(); + + int hcf = findHCF(num1, num2); + int lcm = (num1 * num2) / hcf; + + System.out.println("HCF of " + num1 + " and " + num2 + " is: " + hcf); + System.out.println("LCM of " + num1 + " and " + num2 + " is: " + lcm); + + // Close the scanner to prevent resource leaks + sc.close(); + } + + private static int findHCF(int a, int b) { + while (b != 0) { + int temp = b; + b = a % b; + a = temp; + } + return a; + } +} From 2761b6a5699b3f794230f15399dcbc9b61580b0d Mon Sep 17 00:00:00 2001 From: Krish Date: Wed, 16 Jul 2025 21:02:28 +0530 Subject: [PATCH 5/5] Added Solution for Qustion 5 from Flow --- FLOW_Q5_Krish.java | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 FLOW_Q5_Krish.java diff --git a/FLOW_Q5_Krish.java b/FLOW_Q5_Krish.java new file mode 100644 index 000000000..c6a8d37a6 --- /dev/null +++ b/FLOW_Q5_Krish.java @@ -0,0 +1,29 @@ +//Keep taking numbers as inputs till the user enters ‘x’, after that print sum of all. +public class FLOW_Q5_Krish +{ + public static void main(String[] args) + { + java.util.Scanner sc = new java.util.Scanner(System.in); + int sum = 0; + String input; + + System.out.println("Enter numbers to sum them up. Type 'x' to finish:"); + while (true) { + input = sc.nextLine(); + if (input.equalsIgnoreCase("x")) { + break; + } + try { + int num = Integer.parseInt(input); + sum += num; + } catch (NumberFormatException e) { + System.out.println("Invalid input, please enter a number or 'x' to exit."); + } + } + + System.out.println("The total sum is: " + sum); + + // Close the scanner to prevent resource leaks + sc.close(); + } +}