Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAkashKumar committed Dec 18, 2018
1 parent 54e739a commit b61286f
Show file tree
Hide file tree
Showing 31 changed files with 716 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Pattern/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions Pattern/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Pattern</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions Pattern/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
18 changes: 18 additions & 0 deletions Pattern/src/com/akash/characterExample/CharacterSerial.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.akash.characterExample;

public class CharacterSerial {

public static void main(String[] args) {

char ch = 'A';
int n = 5;
for(int i= 1;i<=n; i++) {
for(int j = 1; j<=i ; j++) {
System.out.print(ch);
}
ch++;
System.out.println();
}
}

}
18 changes: 18 additions & 0 deletions Pattern/src/com/akash/characterSequence/CharacterSequence.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.akash.characterSequence;

public class CharacterSequence {

public static void main(String[] args) {
char ch = 'A';
int n = 5;
for(int i = 1; i<=n ; i++) {
for(int j = 1; j<=i; j++) {
System.out.print(ch);
ch++;
}
//ch++;
System.out.println();
}
}

}
27 changes: 27 additions & 0 deletions Pattern/src/com/akash/diagonal/NumberPatternSeries.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.akash.diagonal;

public class NumberPatternSeries {

public static void main(String[] args) {
int m = 4;
int n = 5;
for(int i = 1; i<=n; i++) {
for(int j = n-i; j>0; j--)
System.out.print(" ");
for(int k =1 ; k<=i; k++)
System.out.print(k+" ");
System.out.println("");
}

for(int i = 1; i<=m; i++) {
for(int j = i; j>0; j--)
System.out.print(" ");
for(int k = 1; k<=n-i; k++)
System.out.print(k+" ");

System.out.println("");
}

}

}
28 changes: 28 additions & 0 deletions Pattern/src/com/akash/diamondPattern/DiamondPattern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.akash.diamondPattern;

public class DiamondPattern {

public static void main(String[] args) {
int n = 6;
int m = 5;

for(int i = 1; i<=n; i++) {
for(int j = n-i; j>0; j--)
System.out.print(" ");
for(int k = 1; k<=2*i-1;k++) {
System.out.print("*"+" ");
}
System.out.println();
}

for(int i = m; i>0; i--) {
for(int j = n-i; j>0 ; j--)
System.out.print(" ");
for(int k = 1; k<=2*i-1; k++) {
System.out.print("*"+" ");
}
System.out.println();
}
}

}
31 changes: 31 additions & 0 deletions Pattern/src/com/akash/diamondShape/DiamondShapeExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.akash.diamondShape;

public class DiamondShapeExample {

public static void main(String[] args) {

int number, i, k, count = 1;
number = 5;
count = number - 1;

for (k = 1; k <= number; k++) {
for (i = 1; i <= count; i++)
System.out.print(" ");
count--;
for (i = 1; i <= 2 * k - 1; i++)
System.out.print("*");
System.out.println();
}
count = 1;
for (k = 1; k <= number - 1; k++) {
for (i = 1; i <= count; i++)
System.out.print(" ");
count++;
for (i = 1; i <= 2 * (number - k) - 1; i++)
System.out.print("*");
System.out.println();

}
}

}
70 changes: 70 additions & 0 deletions Pattern/src/com/akash/diamondShapeAlpha/DiamondShapeAlpha.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.akash.diamondShapeAlpha;

import java.util.Scanner;

public class DiamondShapeAlpha {
// Question : Enter a Char between A to Z : G

public static void main(String[] args) {

char [] letter = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
int letter_number = 0;

// array of string
String[] diamonds = new String[26];

//get the letter
System.out.print("Enter a Char between A to Z");

Scanner reader = new Scanner(System.in);

try {

char user_letter = reader.next("[A-Z]").charAt(0);
// search for letter number in the array letter.

for(int i = 0; i<letter.length; i++) {
if(letter[i] == user_letter) {
letter_number = i;
break;
}
}

// constructor Diamond

for(int i = 0; i<= letter_number; i++) {
diamonds[i] = "";
// add initial spaces
for(int j = 0; j< letter_number-i; j++) {
diamonds[i] = " ";
}

// add letter (first time)
diamonds[i] += letter[i];

// add space between letters
if(letter[i] != 'A') {
for(int j = 0; j<2*i-1;j++) {
diamonds[i] += " ";
}
// add letter (Second time)
diamonds[i] += letter[i];
}
//Draw the first part of the diamond as its composing
System.out.println(diamonds[i]);
}
for(int i = letter_number - 1; i>=0 ; i--) {
// Draw the second part of the diamond
// writing the diamondArray in reverse order.
System.out.println(diamonds[i]);
}

}catch(Exception e) {
e.printStackTrace();
}finally {
reader.close();
}
}

}
48 changes: 48 additions & 0 deletions Pattern/src/com/akash/diamondShapeCompose/DiamondShapeCompose.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.akash.diamondShapeCompose;

public class DiamondShapeCompose {

public static void main(String[] args) {

for (int i = 1; i <= 4; i++)
{
int n = 4;

for (int j = 1; j <= n - i; j++)
{
System.out.print(" ");
}
for (int k = i; k >= 1; k--)
{
System.out.print(k);
}
for (int l = 2; l <= i; l++)
{
System.out.print(l);
}

System.out.println();
}

for (int i = 3; i >= 1; i--)
{
int n = 3;

for (int j = 0; j <= n - i; j++)
{
System.out.print(" ");
}
for (int k = i; k >= 1; k--)
{
System.out.print(k);
}
for (int l = 2; l <= i; l++)
{
System.out.print(l);
}

System.out.println();
}
}

}
23 changes: 23 additions & 0 deletions Pattern/src/com/akash/doubleStar/DoubleStarPattern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.akash.doubleStar;

public class DoubleStarPattern {

public static void main(String[] args) {

int n = 8;
for(int i = 1; i<=n ; i++) {
for(int j = 1; j<=i; j++) {
System.out.print("*");
}
for(int k = 1; k<=1;k++)
System.out.print(" ");

for(int j = 1; j<=i; j++) {
System.out.print("*");
}

System.out.println();
}
}

}
17 changes: 17 additions & 0 deletions Pattern/src/com/akash/floydTrianglePattern/FloydTriangle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.akash.floydTrianglePattern;

public class FloydTriangle {

public static void main(String[] args) {
int i, j, k = 1;

for(i = 0 ; i<=5 ; i++) {
for(j = 1; j<=i+1;j++) {
System.out.print(k++ +" ");

}
System.out.println();
}
}

}
20 changes: 20 additions & 0 deletions Pattern/src/com/akash/lineStar/LineStar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.akash.lineStar;

public class LineStar {

public static void main(String[] args) {

int n = 10;

for(int i = 1; i<=n; i++) {
for(int j = n-i; j>0; j--)
System.out.print(" ");
for(int k = 1; k<=i; k++) {
System.out.print("*");
}
System.out.println();
}

}

}
18 changes: 18 additions & 0 deletions Pattern/src/com/akash/mix/MixNumberNdStar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.akash.mix;

public class MixNumberNdStar {

public static void main(String[] args) {

int n = 5;
for(int i = 1; i<=n; i++) {
for(int j=1; j<=i;j++)
System.out.print(j);
for(int k = n-i; k>0;k--)
System.out.print("*");
System.out.println();
}

}

}
24 changes: 24 additions & 0 deletions Pattern/src/com/akash/numberPatternSame/NumberPatternSame.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.akash.numberPatternSame;

public class NumberPatternSame {

public static void main(String[] args) {

int n = 5;
for(int i = n; i>=0; i--) {
for(int j = 1; j<=i; j++) {
System.out.print(j);
}
System.out.println();
}
System.out.println();

for(int i = 1; i<=n; i++) {
for(int j = 1; j<=i; j++) {
System.out.print(j);
}
System.out.println();
}
}

}
Loading

0 comments on commit b61286f

Please sign in to comment.