Skip to content

Commit d9ed7b9

Browse files
Java Codes
1 parent 99c2def commit d9ed7b9

File tree

164 files changed

+3341
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+3341
-0
lines changed

A8.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
abstract class A8 {
3+
abstract void callme();
4+
5+
void callmetoo() {
6+
System.out.println("This is my Full Name.");
7+
}
8+
}
9+
10+
class B8 extends A8 {
11+
void callme() {
12+
System.out.println("B's implementation of callme.");
13+
}
14+
}
15+
16+
class AbstractDemo {
17+
18+
public static void main(String[] args) {
19+
B8 b = new B8();
20+
21+
b.callme();
22+
b.callmetoo();
23+
}
24+
}

Account.class

432 Bytes
Binary file not shown.

AddMatrix.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
public class AddMatrix {
2+
public static void main(String[] args) {
3+
int m1[][] = { { 1, 2, 3 }, { 2, 5, 7 }, { 6, 8, 9 } };
4+
int m2[][] = { { 5, 4, 3 }, { 6, 1, 3 }, { 4, 7, 9 } };
5+
int sum[][] = new int[3][3];
6+
int i, j;
7+
System.out.println("Elements of first matrix=");
8+
for (i = 0; i < 3; i++) {
9+
for (j = 0; j < 3; j++) {
10+
System.out.println(m1[i][j] + " ");
11+
}
12+
System.out.println();
13+
}
14+
System.out.println("Elements of Second Matrix =");
15+
for (i = 0; i < 3; i++) {
16+
for (j = 0; j < 3; j++) {
17+
System.out.println(m2[i][j] + " ");
18+
}
19+
System.out.println();
20+
}
21+
System.out.println("Addition of two Matrix=");
22+
for (i = 0; i < 3; i++) {
23+
for (j = 0; j < 3; j++) {
24+
sum[i][j] = m1[i][j] + m2[i][j];
25+
}
26+
27+
}
28+
// sum of two matrix
29+
for (i = 0; i < 3; i++) {
30+
for (j = 0; j < 3; j++) {
31+
System.out.println(sum[i][j] + " ");
32+
}
33+
System.out.println();
34+
}
35+
}
36+
37+
}

AlgorithmsDemo.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import java.util.*;
2+
3+
public class AlgorithmsDemo {
4+
5+
public static void main(String[] args) {
6+
LinkedList<Integer> ll = new LinkedList<>();
7+
ll.add(-8);
8+
ll.add(20);
9+
ll.add(-20);
10+
ll.add(8);
11+
12+
Comparator<Integer> r = Collections.reverseOrder();
13+
14+
Collections.sort(ll, r);
15+
16+
System.out.print("List sorted in reverse: ");
17+
for (int i : ll)
18+
System.out.print(i + " ");
19+
20+
System.out.println();
21+
22+
Collections.shuffle(ll);
23+
24+
System.out.print("List shuffled: ");
25+
for (int i : ll)
26+
System.out.print(i + " ");
27+
28+
System.out.println();
29+
System.out.println("Minimum: " + Collections.min(ll));
30+
System.out.println("Maximum: " + Collections.max(ll));
31+
}
32+
}

AmountPurchase.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import java.util.Scanner;
2+
3+
public class AmountPurchase {
4+
public static void main(String[] args) {
5+
double Discount;
6+
double amount;
7+
Scanner n = new Scanner(System.in);
8+
System.out.println("enter Your Purchase amount=");
9+
amount = n.nextDouble();
10+
if (amount >= 8000) {
11+
Discount = ((amount / 100) * 10);
12+
amount = amount - Discount;
13+
14+
System.out.println("Final amount= " + amount);
15+
System.out.println("Discount= " + Discount);
16+
} else if (amount >= 5000)
17+
Discount = ((amount / 100) * 8);
18+
amount = amount - Discount;
19+
20+
System.out.println("Final amount= " + amount);
21+
System.out.println("Discount=" + Discount);
22+
23+
}
24+
}

Arithmetic.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
public class Arithmetic {
3+
4+
}

ArmstrongNumber.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import java.util.Scanner;
2+
3+
public class ArmstrongNumber {
4+
public static void main(String[] args) {
5+
6+
int number = 371, originalNumber, remainder, result = 0;
7+
8+
originalNumber = number;
9+
10+
while (originalNumber != 0) {
11+
remainder = originalNumber % 10;
12+
result += Math.pow(remainder, 3);
13+
originalNumber /= 10;
14+
}
15+
16+
if (result == number)
17+
System.out.println(number + " is an Armstrong number.");
18+
else
19+
System.out.println(number + " is not an Armstrong number.");
20+
}
21+
}

Array.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public class Array {
2+
public static void main(String[] args) {
3+
int[] marks = new int[5];
4+
marks[0] = 100;
5+
marks[1] = 60;
6+
marks[3] = 70;
7+
marks[4] = 80;
8+
marks[5] = 90;
9+
System.out.println(marks[3]);
10+
11+
}
12+
13+
}

Array1.class

808 Bytes
Binary file not shown.

Array1.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import java.util.Scanner;
2+
3+
public class Array1 {
4+
public static void main(String[] args) {
5+
6+
int i, j;
7+
Scanner sc = new Scanner(System.in);
8+
System.out.println("Enter the number of rows");
9+
int rows = sc.nextInt();
10+
System.out.println("enter the number of column");
11+
int cols = sc.nextInt();
12+
int a[][] = new int[rows][cols];
13+
for (i = 0; i < rows; i++) {
14+
for (j = 0; j < cols; j++) {
15+
16+
}
17+
}
18+
19+
}
20+
21+
}

0 commit comments

Comments
 (0)