From 6535c39f11f71d5bebb67463acfb098bbc0afa0f Mon Sep 17 00:00:00 2001 From: "Er. Shiva K. Shrestha" Date: Wed, 2 Aug 2017 14:04:23 +0545 Subject: [PATCH 1/9] Pattern5 --- Pattern5.java | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Pattern5.java diff --git a/Pattern5.java b/Pattern5.java new file mode 100644 index 0000000..b4094a4 --- /dev/null +++ b/Pattern5.java @@ -0,0 +1,31 @@ +package javapatternsmorning; + +/** + * + * @author ErSKS + */ +public class Pattern5 { + + public static void p() { + System.out.println("\nPattern5"); + int n = 9; + for (int i = 1; i <= n; i++) { + for (int j = n - i; j > 0; j--) { + System.out.print(" "); + } + for (int j = 1; j <= i; j++) { + System.out.print("*"); + } + System.out.println(""); + } + for (int i = 1; i < n; i++) { + for (int j = 1; j <= i; j++) { + System.out.print(" "); + } + for (int j = n - i; j > 0; j--) { + System.out.print("*"); + } + System.out.println(""); + } + } +} From 64438b06aeb200577daca909dc5d67f3c7dcee61 Mon Sep 17 00:00:00 2001 From: "Er. Shiva K. Shrestha" Date: Wed, 2 Aug 2017 14:04:56 +0545 Subject: [PATCH 2/9] Pattern6 --- Pattern6.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Pattern6.java diff --git a/Pattern6.java b/Pattern6.java new file mode 100644 index 0000000..30a0c65 --- /dev/null +++ b/Pattern6.java @@ -0,0 +1,24 @@ +package javapatternsmorning; + +/** + * + * @author ErSKS + */ +public class Pattern6 { + + public static void p() { + System.out.println("\nPattern6"); + int n = 9; + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= n - i; j++) { + System.out.print(" "); + } + for (int k = 1; k <= i; k++) { + System.out.print(" *"); + } + System.out.println(" "); + + } + + } +} From 1c23948be1136eeb8e881183c72f6c3179fc02d2 Mon Sep 17 00:00:00 2001 From: "Er. Shiva K. Shrestha" Date: Wed, 2 Aug 2017 14:06:45 +0545 Subject: [PATCH 3/9] Pattern21 --- Pattern21.java | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Pattern21.java diff --git a/Pattern21.java b/Pattern21.java new file mode 100644 index 0000000..6385e5b --- /dev/null +++ b/Pattern21.java @@ -0,0 +1,42 @@ +package javapatternsmorning; + +/** + * + * @author ErSKS + */ +public class Pattern21 { + + public static void p() { + System.out.println("\nPattern21"); + final int N = 15, M = N / 2 + 1; + for (int i = 1; i <= N - M; i++) { + for (int j = 1; j <= N; j++) { + if (j <= i || j > N - i) { + if (j % 2 == 1) { + System.out.print("1 "); + } else { + System.out.print("0 "); + } + } else { + System.out.print(" "); + } + } + System.out.println(); + } + + for (int i = N - M + 1; i <= N; i++) { + for (int j = 1; j <= N; j++) { + if (j <= M - (i - M) || j >= M + (i - M)) { + if (j % 2 == 1) { + System.out.print("1 "); + } else { + System.out.print("0 "); + } + } else { + System.out.print(" "); + } + } + System.out.println(); + } + } +} From e3c568e64f2ab4caeaf6dd346639593cf4851637 Mon Sep 17 00:00:00 2001 From: "Er. Shiva K. Shrestha" Date: Wed, 2 Aug 2017 14:20:36 +0545 Subject: [PATCH 4/9] LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d46c4f5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Er. Shiva K. Shrestha + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 90523b1e716468724cc8fca9ef29d0024af92915 Mon Sep 17 00:00:00 2001 From: "Er. Shiva K. Shrestha" Date: Wed, 2 Aug 2017 14:22:58 +0545 Subject: [PATCH 5/9] Contribute your work --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..ae15e8d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1 @@ +Sumbit your Java Code as per Question given in issues of this directory/project. From c637cb9a291274a33fbf1cd6fe930798c36ccc86 Mon Sep 17 00:00:00 2001 From: "Er. Shiva K. Shrestha" Date: Wed, 2 Aug 2017 14:26:39 +0545 Subject: [PATCH 6/9] Code of Conduct --- CODE_OF_CONDUCT.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..e410ec3 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,32 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Behavior that contributes to creating a positive environment include: + +* Using Java Programming Language + + +## Our Responsibilities + +* Releasing Java Code for optimization + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at shrestha.shiva@hotmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ From df53417e86d06ae2c2503440d1f78bd5dfe15b2d Mon Sep 17 00:00:00 2001 From: "Er. Shiva K. Shrestha" Date: Sun, 13 Aug 2017 07:32:00 +0545 Subject: [PATCH 7/9] Prime Number Checker --- PrimeNumber.java | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 PrimeNumber.java diff --git a/PrimeNumber.java b/PrimeNumber.java new file mode 100644 index 0000000..53a2010 --- /dev/null +++ b/PrimeNumber.java @@ -0,0 +1,48 @@ +package cjt; + +/** + * + * @author ErSKS + */ +public class PrimeNumber { + + public static void main(String[] args) { + System.out.println("Q1. Checking Prime Numbers:"); + System.out.println("Prime Check: 0 false:" + isPrime(0)); + System.out.println("Prime Check: 1 false:" + isPrime(1)); + System.out.println("Prime Check: 2 true:" + isPrime(2)); + System.out.println("Prime Check: 3 true:" + isPrime(3)); + System.out.println("Prime Check: 4 false:" + isPrime(4)); + System.out.println("Prime Check: -4 false:" + isPrime(-4)); + + System.out.println("\nGenerating Prime Numbers less than 100:"); + generatePrimes(100); + System.out.println("\n"); + } + + static boolean isPrime(int n) { + if (n < 2) { + return false; + } + int countFactor = 0; + boolean result = true; + for (int i = 1; i < n && result == true; i++) { + if (n % i == 0) { + countFactor++; + } + if (countFactor > 1) { + result = false; + } + } + return result; + } + + static void generatePrimes(int n) { + + for (int i = 1; i < n; i++) { + if (isPrime(i) == true) { + System.out.print(i + " "); + } + } + } +} From 97cb62e3d88445f9d184f0a06ed896fd7b8fa717 Mon Sep 17 00:00:00 2001 From: "Er. Shiva K. Shrestha" Date: Fri, 25 Aug 2017 06:13:39 +0545 Subject: [PATCH 8/9] Code for MySQL Database Connection --- MySQLConnect.java | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 MySQLConnect.java diff --git a/MySQLConnect.java b/MySQLConnect.java new file mode 100644 index 0000000..5aca958 --- /dev/null +++ b/MySQLConnect.java @@ -0,0 +1,29 @@ +package proj_mysqlconnect; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import javax.swing.JOptionPane; + +/** + * + * @author ErSKS + */ +public class MySQLConnect { + + public static Connection conn; + + public static Connection connectDb() { + try { + Class.forName("com.mysql.jdbc.Driver"); + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/cjt_db", "nepal", "Kt6tRCbCjq7PzXx9"); + System.out.println("Database Connected Successfully !"); + return conn; + } catch (ClassNotFoundException | SQLException e) { + System.out.println(e.getMessage()); + JOptionPane.showMessageDialog(null, "Database cannot be connected !"); + System.exit(0); + } + return null; + } +} From e2c3721c8fb387a65035455e25a04fee733edf73 Mon Sep 17 00:00:00 2001 From: "Er. Shiva K. Shrestha" Date: Sun, 27 Aug 2017 13:39:38 +0545 Subject: [PATCH 9/9] Code to Connect MySQL Database --- MySQLConnect.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MySQLConnect.java b/MySQLConnect.java index 5aca958..56c9568 100644 --- a/MySQLConnect.java +++ b/MySQLConnect.java @@ -16,7 +16,7 @@ public class MySQLConnect { public static Connection connectDb() { try { Class.forName("com.mysql.jdbc.Driver"); - conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/cjt_db", "nepal", "Kt6tRCbCjq7PzXx9"); + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/java_db", "java", ""); System.out.println("Database Connected Successfully !"); return conn; } catch (ClassNotFoundException | SQLException e) {