├── README.md └── introduction ├── Java If-Else.java ├── Java Loops I.java ├── Java Stdin and Stdout I.java ├── Java Stdin and Stdout II.java ├── JavaInttoString.java ├── MatrixAddition.java ├── MatrixMultiplication.java ├── Prime Number ├── README.md ├── ReverseNumber.java └── Welcome to Java!.java /README.md: -------------------------------------------------------------------------------- 1 | # Java 2 | Hackerrank 3 | -------------------------------------------------------------------------------- /introduction/Java If-Else.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.math.*; 3 | import java.security.*; 4 | import java.text.*; 5 | import java.util.*; 6 | import java.util.concurrent.*; 7 | import java.util.regex.*; 8 | 9 | public class Solution { 10 | 11 | 12 | 13 | private static final Scanner scanner = new Scanner(System.in); 14 | 15 | public static void main(String[] args) { 16 | int N = scanner.nextInt(); 17 | if(N%2==1) 18 | System.out.println("Weird"); 19 | else 20 | if(N>=2 && N<=5) 21 | System.out.println("Not Weird"); 22 | else if(N>=6 && N<=20) 23 | System.out.println("Weird"); 24 | else if(N>20) 25 | System.out.println("Not Weird"); 26 | scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); 27 | 28 | scanner.close(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /introduction/Java Loops I.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.math.*; 3 | import java.security.*; 4 | import java.text.*; 5 | import java.util.*; 6 | import java.util.concurrent.*; 7 | import java.util.regex.*; 8 | 9 | public class Solution { 10 | 11 | 12 | 13 | private static final Scanner scanner = new Scanner(System.in); 14 | 15 | public static void main(String[] args) { 16 | int N = scanner.nextInt(); 17 | for(int i=1;i<=10;i++) 18 | { 19 | 20 | System.out.printf("%d x %d = %d%n", N, i, N*i); 21 | 22 | scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); 23 | 24 | } 25 | scanner.close(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /introduction/Java Stdin and Stdout I.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class Solution { 4 | 5 | public static void main(String[] args) { 6 | Scanner scan = new Scanner(System.in); 7 | int a = scan.nextInt(); 8 | // Complete this line 9 | // Complete this line 10 | int b = scan.nextInt(); 11 | int c = scan.nextInt(); 12 | 13 | System.out.println(a); 14 | System.out.println(b); 15 | System.out.println(c); 16 | 17 | // Complete this line 18 | // Complete this line 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /introduction/Java Stdin and Stdout II.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class Solution { 4 | 5 | public static void main(String[] args) { 6 | Scanner scan = new Scanner(System.in); 7 | int i = scan.nextInt(); 8 | 9 | 10 | // Write your code here. 11 | double d=scan.nextDouble(); 12 | scan.nextLine(); 13 | String s = scan.nextLine(); 14 | //String s=scan.next(); 15 | 16 | System.out.println("String: " + s); 17 | System.out.println("Double: " + d); 18 | System.out.println("Int: " + i); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /introduction/JavaInttoString.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class JavaInttoString { 3 | public static void main(String[] args) { 4 | //Write your code here 5 | String s =Integer.toString(n); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /introduction/MatrixAddition.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | public class MatrixAddition 5 | { 6 | public static void main(String[] args) 7 | { 8 | Scanner sc = new Scanner(System.in); 9 | int n1 = sc.nextInt(); 10 | int[][] ar1 = new int[n1][n1]; 11 | 12 | for(int i = 0 ; i Here is the problems link 2 | -------------------------------------------------------------------------------- /introduction/ReverseNumber.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class ReverseNumber { 4 | public static void main(String[] args) { 5 | Scanner sc = new Scanner(System.in); 6 | 7 | int num = sc.nextInt(); 8 | int rev = 0; 9 | 10 | while(num != 0){ 11 | rev = (rev*10) + (num % 10); 12 | num = num / 10; 13 | } 14 | System.out.println("Reverse of the number : "+rev); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /introduction/Welcome to Java!.java: -------------------------------------------------------------------------------- 1 | public class Solution { 2 | 3 | public static void main(String[] args) { 4 | System.out.println("Hello, World."); 5 | System.out.println("Hello, Java."); 6 | 7 | /* Enter your code here. Print output to STDOUT. Your class should be named Solution. */ 8 | } 9 | } 10 | --------------------------------------------------------------------------------