diff --git a/Java Coding Challenges/CC_01.java b/Java Coding Challenges/CC_01.java new file mode 100644 index 0000000..94b5c59 --- /dev/null +++ b/Java Coding Challenges/CC_01.java @@ -0,0 +1,18 @@ +import java.util.*; + +public class CC_01 { + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.print("Input: "); + int n1 = sc.nextInt(); + int n2 = sc.nextInt(); + int sum = n1 + n2; + int sub = n1 - n2; + int mul = n1 * n2; + int div = n1 / n2; + int mod = n1 % n2; + System.out.printf("Output: Sum: %d Sub: %d Mul: %d Div: %d Mod: %d", sum, sub, mul, div, mod); + } + +} diff --git a/Java Coding Challenges/CC_02.java b/Java Coding Challenges/CC_02.java new file mode 100644 index 0000000..29fd12c --- /dev/null +++ b/Java Coding Challenges/CC_02.java @@ -0,0 +1,18 @@ +import java.util.*; + +public class CC_02 { + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.print("Input: "); + int n = sc.nextInt(); + if(n%2==0) { + System.out.print("Output: "+ "Even"); + } + else { + System.out.print("Output: "+ "Odd"); + } + + } + +} diff --git a/Java Coding Challenges/CC_03.java b/Java Coding Challenges/CC_03.java new file mode 100644 index 0000000..138544c --- /dev/null +++ b/Java Coding Challenges/CC_03.java @@ -0,0 +1,12 @@ +import java.util.Scanner; + +public class CC_03 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.print("Input: "); + float r = sc.nextFloat(); + double area = 3.14*r*r; + System.out.println("Output: "+ area); + } + +} diff --git a/Java Coding Challenges/CC_04.java b/Java Coding Challenges/CC_04.java new file mode 100644 index 0000000..1da8ebe --- /dev/null +++ b/Java Coding Challenges/CC_04.java @@ -0,0 +1,16 @@ +import java.util.*; +public class CC_04 { + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.print("Input: "); + int n1 = sc.nextInt(); + int n2 = sc.nextInt(); + int n3; + n3 = n1; + n1 = n2; + n2 = n3; + System.out.printf("Output: n1=%d n2=%d", n1, n2); + } + +} diff --git a/Java Coding Challenges/CC_05.java b/Java Coding Challenges/CC_05.java new file mode 100644 index 0000000..e5f8fb1 --- /dev/null +++ b/Java Coding Challenges/CC_05.java @@ -0,0 +1,18 @@ +import java.util.Scanner; +public class CC_05 { + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.print("Input: "); + int n1 = sc.nextInt(); + int n2 = sc.nextInt(); + if(n1>n2) { + System.out.printf("Min=%d Max=%d", n2, n1); + } + else { + System.out.printf("Min=%d Max=%d", n1, n2); + } + + } + +} diff --git a/Java Coding Challenges/CC_06.java b/Java Coding Challenges/CC_06.java new file mode 100644 index 0000000..bf58627 --- /dev/null +++ b/Java Coding Challenges/CC_06.java @@ -0,0 +1,15 @@ +import java.util.Scanner; +public class CC_06 { + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.print("Input: "); + int n1 = sc.nextInt(); + int n2 = sc.nextInt(); + int n3 = sc.nextInt(); + int min = n1n2 && n1>n3 ? n1 : n2>n1 && n2>n3 ? n2 : n3; + System.out.printf("Min = %d Max = %d", min, max); + } + +} diff --git a/Java Coding Challenges/CC_07.java b/Java Coding Challenges/CC_07.java new file mode 100644 index 0000000..56eb5d8 --- /dev/null +++ b/Java Coding Challenges/CC_07.java @@ -0,0 +1,14 @@ +import java.util.Scanner; +public class CC_07 { + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.print("Input: "); + int n1 = sc.nextInt(); + int n2 = sc.nextInt(); + int n3 = sc.nextInt(); + int second = n1>n2&&n1>n3?n2>n3?n2:n3 : n2>n1&&n2>n3?n1>n3?n1:n3 : n1>n2?n1:n2; + System.out.print("Output: " + second); + } + +} diff --git a/Java Coding Challenges/CC_08.java b/Java Coding Challenges/CC_08.java new file mode 100644 index 0000000..4ee1d93 --- /dev/null +++ b/Java Coding Challenges/CC_08.java @@ -0,0 +1,30 @@ +import java.util.*; + +public class CC_08 { + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int[] arr = {3,6,4,0,1,5,6}; + System.out.print("Original Array: "); + for(int i=0; iarr[j]) { + temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + System.out.println(); + System.out.print("Sorted Array: "); + for(int i=0; i