diff --git a/FLOW_Q3_Krish.java b/FLOW_Q3_Krish.java new file mode 100644 index 000000000..cc3bbe5c9 --- /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/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; + } +} 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(); + } +} 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__