-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sreeram
committed
Nov 9, 2019
1 parent
0949647
commit f320d14
Showing
65 changed files
with
1,212 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#BlueJ class context | ||
comment0.target=ArraySorting | ||
comment1.params=args | ||
comment1.target=void\ main(java.lang.String[]) | ||
numComments=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import java.util.*; | ||
class ArraySorting | ||
{ | ||
public static void main(String args[]) | ||
{ | ||
Scanner sc = new Scanner(System.in); | ||
System.out.println("Enter the number of rows"); | ||
int m =sc.nextInt(); | ||
System.out.println("Enter the number of coloumns"); | ||
int n =sc.nextInt(); | ||
int A[][]=new int[m][n]; | ||
int B[][]=new int[m][n]; | ||
System.out.println("Enter the elements"); | ||
for(int i=0;i<m;i++) | ||
{ | ||
for(int j=0;j<n;j++) | ||
{ | ||
A[i][j]=sc.nextInt(); | ||
} | ||
} | ||
for(int i=0;i<m;i++)//Making dupliacte matrix to sort by coulmn | ||
{ | ||
for(int j=0;j<n;j++) | ||
{ | ||
B[i][j]=A[i][j]; | ||
} | ||
} | ||
System.out.println("\n"); | ||
System.out.println("ORIGINAL MATRIX :"); | ||
for(int i=0;i<m;i++) | ||
{ | ||
for(int j=0;j<n;j++) | ||
System.out.print(A[i][j]+"\t"); | ||
System.out.println(); | ||
} | ||
System.out.println(); | ||
for (int i = 0; i < m; i++) | ||
{ | ||
for (int j = 0; j < n; j++) | ||
{ | ||
for (int k = 0; k <m-j-1; k++) | ||
{ | ||
if (A[i][k] > A[i][k+1]) | ||
{ | ||
int t = A[i][k]; | ||
A[i][k] = A[i][k + 1]; | ||
A[i][k + 1] = t; | ||
} | ||
} | ||
} | ||
} | ||
System.out.println("SORTED BY ROW :"); | ||
for(int i=0;i<m;i++) | ||
{ | ||
for(int j=0;j<n;j++) | ||
System.out.print(A[i][j]+"\t"); | ||
System.out.println(); | ||
} | ||
for(int i = 0; i < n; i++){ | ||
for(int j = 0; j < m; j++){ | ||
for(int k = 0; k < m - 1 - j; k++){ | ||
if(B[k][i] > B[k + 1][i]){ | ||
int temp = B[k][i]; | ||
B[k][i] = B[k + 1][i]; | ||
B[k + 1][i] = temp; | ||
} | ||
} | ||
} | ||
} | ||
System.out.println("\nSORTED BY COLUMN\n"); | ||
for(int i=0;i<m;i++) | ||
{ | ||
for(int j=0;j<n;j++) | ||
System.out.print(B[i][j]+"\t"); | ||
System.out.println(); | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#BlueJ class context | ||
comment0.target=DateGenarator | ||
comment1.params= | ||
comment1.target=void\ gen() | ||
comment2.params=a | ||
comment2.target=boolean\ leapyear(int) | ||
comment3.params=args | ||
comment3.target=void\ main(java.lang.String[]) | ||
numComments=4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import java.util.*; | ||
class DateGenarator | ||
{ | ||
void gen() | ||
{ | ||
Scanner sc = new Scanner(System.in); | ||
System.out.println("DATE GENERATOR"); | ||
System.out.println("Enter a number(th day) 1-366"); | ||
int d = sc.nextInt(); | ||
System.out.println("Enter the Year"); | ||
int y = sc.nextInt(); | ||
boolean l = leapyear(y); | ||
if(d <1 || d>366) | ||
System.exit(0); | ||
if(l) | ||
{ | ||
if(d>=1 && d<=31) | ||
System.out.println(d +", January,"+y); | ||
else if(d>=32 && d<=60) | ||
System.out.println(d-31 +", February,"+y); | ||
else if(d>=61 && d<=91) | ||
System.out.println(d-60 +", March,"+y); | ||
else if(d>=92 && d<=121) | ||
System.out.println(d-91 +", April,"+y); | ||
else if(d>=122 && d<=152) | ||
System.out.println(d-121 +", May,"+y); | ||
else if(d>=153 && d<=182) | ||
System.out.println(d-152 +", June,"+y); | ||
else if(d>=183 && d<=213) | ||
System.out.println(d-182 +", July,"+y); | ||
else if(d>=214 && d<=244) | ||
System.out.println(d-213 +", August,"+y); | ||
else if(d>=245 && d<=274) | ||
System.out.println(d-244 +", September,"+y); | ||
else if(d>=275 && d<=305) | ||
System.out.println(d-274 +", October,"+y); | ||
else if(d>=306 && d<=335) | ||
System.out.println(d-305 +", November,"+y); | ||
else if(d>=336 && d<=366) | ||
System.out.println(d-335 +", December,"+y); | ||
} | ||
else | ||
{ | ||
if(d>=1 && d<=31) | ||
System.out.println(d +", January,"+y); | ||
else if(d>=32 && d<=59) | ||
System.out.println(d-31 +", February,"+y); | ||
else if(d>=59 && d<=90) | ||
System.out.println(d-58 +", March,"+y); | ||
else if(d>=91 && d<=120) | ||
System.out.println(d-90 +", April,"+y); | ||
else if(d>=121 && d<=151) | ||
System.out.println(d-120 +", May,"+y); | ||
else if(d>=152 && d<=181) | ||
System.out.println(d-151 +", June,"+y); | ||
else if(d>=182 && d<=212) | ||
System.out.println(d-181 +", July,"+y); | ||
else if(d>=213 && d<=243) | ||
System.out.println(d-212 +", August,"+y); | ||
else if(d>=244 && d<=273) | ||
System.out.println(d-243 +", September,"+y); | ||
else if(d>=274 && d<=304) | ||
System.out.println(d-273 +", October,"+y); | ||
else if(d>=305 && d<=334) | ||
System.out.println(d-304 +", November,"+y); | ||
else if(d>=335 && d<=365) | ||
System.out.println(d-334 +", December,"+y); | ||
} | ||
} | ||
static boolean leapyear(int a) | ||
{ | ||
if(a%4==0) | ||
return true; | ||
else | ||
return false; | ||
} | ||
public static void main(String args[])throws Exception | ||
{ | ||
DateGenarator DG = new DateGenarator(); | ||
DG.gen(); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#BlueJ class context | ||
comment0.target=Denomination | ||
comment1.params= | ||
comment1.target=Denomination() | ||
comment2.params= | ||
comment2.target=int\ get() | ||
comment3.params= | ||
comment3.target=void\ check() | ||
comment4.params= | ||
comment4.target=void\ calprint() | ||
comment5.params=args | ||
comment5.target=void\ main(java.lang.String[]) | ||
numComments=6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import java.util.*; | ||
class Denomination | ||
{ | ||
int amt; | ||
Denomination() | ||
{ | ||
amt=0; | ||
} | ||
int get() | ||
{ | ||
Scanner sc=new Scanner(System.in); | ||
System.out.println("Enter the amount:"); | ||
amt=sc.nextInt(); | ||
String s=""+amt; | ||
int l=s.length(); | ||
return l; | ||
} | ||
void check() | ||
{ | ||
int l=get(); | ||
if(l>5) | ||
System.out.println("INVALID AMOUNT"); | ||
else | ||
calprint(); | ||
} | ||
void calprint() | ||
{ | ||
int n=amt, rev=0,total=0,totaln=0,div; | ||
String word[]={"ZERO","ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE"}; | ||
int notes[]={1000,500,100,50,20,10,5,2,1}; | ||
while(n>0) | ||
{ | ||
rev=(rev*10)+(n%10); | ||
n/=10; | ||
} | ||
while(rev>0) | ||
{ | ||
System.out.print(word[rev%10]+" "); | ||
rev/=10; | ||
} | ||
System.out.println(); | ||
System.out.println("DENOMINATION:"); | ||
for(int i=0;i<9;i++) | ||
{ | ||
div=amt/notes[i]; | ||
amt%=notes[i]; | ||
if(div>0) | ||
{ | ||
System.out.println(notes[i]+"\tX\t"+div+"\t=\t"+(notes[i]*div)); | ||
total+=notes[i]*div; | ||
totaln+=div; | ||
} | ||
} | ||
System.out.println("TOTAL="+total); | ||
System.out.println("TOTAL NUMBER OF NOTES:"+totaln); | ||
} | ||
public static void main(String args[]) | ||
{ | ||
Denomination denom = new Denomination(); | ||
denom.check(); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#BlueJ class context | ||
comment0.target=FibonacciCalc | ||
comment1.params=n | ||
comment1.target=int\ fibonacciRecursion(int) | ||
comment2.params=args | ||
comment2.target=void\ main(java.lang.String[]) | ||
numComments=3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import java.util.*; | ||
class FibonacciCalc | ||
{ | ||
static int fibonacciRecursion(int n) | ||
{ | ||
if(n == 0) | ||
return 0; | ||
if(n == 1 || n == 2) | ||
return 1; | ||
return fibonacciRecursion(n-2) + fibonacciRecursion(n-1); | ||
} | ||
public static void main(String args[]) | ||
{ | ||
Scanner sc=new Scanner(System.in); | ||
System.out.println("Enter the limit of the Fibonacci Series"); | ||
int n=sc.nextInt(); | ||
System.out.print("First "+n+" Fibonacci numbers are: "); | ||
for(int i = 0; i < n; i++) | ||
System.out.print(fibonacciRecursion(i) +" "); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#BlueJ class context | ||
comment0.target=InsertionSort | ||
comment1.params=arr | ||
comment1.target=void\ sort(int[]) | ||
comment2.params=args | ||
comment2.target=void\ main(java.lang.String[]) | ||
numComments=3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import java.util.*; | ||
class InsertionSort | ||
{ | ||
static void sort(int arr[]) | ||
{ | ||
int N = arr.length; | ||
int i, j, temp; | ||
for (i = 1; i< N; i++) | ||
{ | ||
j = i; | ||
temp = arr[i]; | ||
while (j > 0 && temp < arr[j-1]) | ||
{ | ||
arr[j] = arr[j-1]; | ||
j = j-1; | ||
} | ||
arr[j] = temp; | ||
} | ||
} | ||
public static void main(String[] args) | ||
{ | ||
Scanner sc = new Scanner( System.in ); | ||
System.out.println("Insertion Sort \n"); | ||
int n, i; | ||
System.out.println("Enter number of integer elements"); | ||
n = sc.nextInt(); | ||
int arr[] = new int[ n ]; | ||
System.out.println("Enter "+ n +" integer elements"); | ||
for (i = 0; i < n; i++) | ||
arr[i] = sc.nextInt(); | ||
sort(arr); | ||
System.out.println("\nElements after sorting "); | ||
for (i = 0; i < n; i++) | ||
System.out.print(arr[i]+" "); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#BlueJ class context | ||
comment0.target=LcmGcd | ||
comment1.params=a\ b | ||
comment1.target=int\ lcm(int,\ int) | ||
comment2.params=a\ b | ||
comment2.target=int\ gcd(int,\ int) | ||
comment3.params=args | ||
comment3.target=void\ main(java.lang.String[]) | ||
numComments=4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import java.util.*; | ||
class LcmGcd | ||
{ | ||
static int i=1; | ||
|
||
static int lcm(int a,int b) | ||
{ | ||
if(a%b==0) | ||
return a; | ||
else | ||
return lcm(a+a/i++,b); | ||
} | ||
static int gcd(int a,int b) | ||
{ | ||
if (a==0) | ||
return b; | ||
else | ||
return gcd(b%a,a); | ||
} | ||
public static void main(String[]args) | ||
{ | ||
LcmGcd obj=new LcmGcd(); | ||
Scanner sc=new Scanner(System.in); | ||
System.out.println("Enter the 2 numbers to find its HCF or LCM"); | ||
int a=sc.nextInt(); | ||
int b=sc.nextInt(); | ||
System.out.println("Enter 1 to find LCM or 2 to find HCF of the given numbers"); | ||
int c=sc.nextInt(); | ||
if(c==1) | ||
System.out.println("The LCM of the given numbers is: "+ lcm(a,b)); | ||
else if(c==2) | ||
System.out.println("The GCD of the given numbers is: "+ gcd(a,b)); | ||
else | ||
System.out.println("Please recheck your selection"); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#BlueJ class context | ||
comment0.target=Permutations | ||
comment1.params=cad\ rem | ||
comment1.target=void\ permutations(java.lang.String,\ java.lang.String) | ||
comment2.params=args | ||
comment2.target=void\ main(java.lang.String[]) | ||
numComments=3 |
Oops, something went wrong.