Skip to content

Commit 549d896

Browse files
authored
Add files via upload
0 parents  commit 549d896

39 files changed

+788
-0
lines changed

Account.java

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package PACKAGEJAVA;
2+
3+
import java.util.Scanner;
4+
5+
public class Account {
6+
static String Name;
7+
static long cardno;
8+
static int pin;
9+
10+
public static void accountDetails() {
11+
System.out.println("The Name is : "+Name);
12+
System.out.println("The Card No is : "+cardno);
13+
System.out.println("The Pin is : "+pin);
14+
}
15+
16+
public static void main(String[] args) {
17+
System.out.print("Enter the Name : ");
18+
Scanner sw = new Scanner(System.in);
19+
Name = sw.nextLine();
20+
System.out.print("Enter the Card No : ");
21+
cardno = sw.nextLong();
22+
System.out.print("Enter your Pin : ");
23+
pin = sw.nextInt();
24+
accountDetails();
25+
sw.close();
26+
}
27+
}

Armstrong.java

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package JAVACTOOOD;
2+
3+
import java.util.Scanner;
4+
5+
public class Armstrong {
6+
7+
public void displayAll(int n) {
8+
System.out.println("The Numbers are : ");
9+
for(int i = 0; i <= n; i++) {
10+
int count = 0;
11+
int sum = 0;
12+
int temp = i;
13+
while(temp > 0) {
14+
temp = temp / 10;
15+
count++;
16+
}
17+
if(count >= 2) {
18+
temp = i;
19+
while(temp > 0) {
20+
int r = temp % 10;
21+
sum = sum + (r*r*r);
22+
}
23+
if(sum == i) {
24+
System.out.println(i);
25+
}
26+
}
27+
else {
28+
System.out.println(i);
29+
}
30+
}
31+
}
32+
33+
public void checkArmstrong(int num) {
34+
int sum = 0, temp = num;
35+
while(temp > 0) {
36+
int r = temp % 10;
37+
temp = temp / 10;
38+
sum = sum + (r * r * r);
39+
}
40+
41+
if(sum == num) {
42+
System.out.println("True");
43+
}
44+
45+
else {
46+
System.out.println("False");
47+
}
48+
}
49+
50+
public static void main(String[] argv) {
51+
System.out.println("Enter the Value to Check : ");
52+
Scanner sc = new Scanner(System.in);
53+
int num = sc.nextInt();
54+
System.out.println("Enter the number to print the values till a Number : ");
55+
int display = sc.nextInt();
56+
Armstrong sr = new Armstrong();
57+
sr.checkArmstrong(num);
58+
sr.displayAll(display);
59+
}
60+
}

Checker.java

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package p1;
2+
3+
public class Checker {
4+
static int num;
5+
public void checkArmstrong(int num) {
6+
int sum = 0, temp = num;
7+
while(temp > 0) {
8+
int r = temp % 10;
9+
temp = temp / 10;
10+
sum = sum + (r * r * r);
11+
}
12+
if(sum == num) {
13+
System.out.println("True");
14+
}
15+
else {
16+
System.out.println("False");
17+
}
18+
}
19+
20+
public boolean isPalindrome(int num) {
21+
Utility rev = new Utility();
22+
if(rev.Reverse(num) == num) {
23+
return true;
24+
}
25+
else {
26+
return false;
27+
}
28+
}
29+
30+
}

Circle.java

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package JAVACTOOOD;
2+
3+
import java.util.Scanner;
4+
5+
public class Circle {
6+
7+
int rad;
8+
9+
public void area() {
10+
double ar = 3.142 * (rad * rad);
11+
System.out.println("The Area of Circle is : "+ar);
12+
}
13+
14+
public void perimeter() {
15+
double pr = 2 * 3.142 * rad;
16+
System.out.println("The Perimeter of Circle is : "+pr);
17+
}
18+
19+
public static void main(String[] argv) {
20+
System.out.println("Enter the Radius : ");
21+
Scanner le = new Scanner(System.in);
22+
Circle cc = new Circle();
23+
cc.rad = le.nextInt();
24+
cc.area();
25+
cc.perimeter();
26+
}
27+
}

Comparetow.java

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package JAVACTOOOD;
2+
3+
import java.util.Scanner;
4+
5+
public class Comparetow {
6+
7+
public static void main(String[] argv) {
8+
int a,b;
9+
System.out.println("Enter the Value 'A' : ");
10+
Scanner r1 = new Scanner(System.in);
11+
a = r1.nextInt();
12+
System.out.println("Enter the Value 'B' : ");
13+
Scanner r2 = new Scanner(System.in);
14+
b = r2.nextInt();
15+
System.out.println("The Value of A is : "+a + " and Value of B is : "+b);
16+
if(a > b) {
17+
System.out.println("A is big and value is : "+a);
18+
}
19+
20+
else {
21+
System.out.println("B is big and value is : "+b);
22+
}
23+
}
24+
}

Cuboid.java

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package JAVACTOOOD;
2+
3+
import java.util.Scanner;
4+
5+
public class Cuboid {
6+
7+
int len,br,he;
8+
9+
public void area() {
10+
int ar = 2*(len*he + len*br + he*br);
11+
System.out.println("The Area of Cuboid is : "+ar);
12+
}
13+
14+
public void perimeter() {
15+
int pr = 4*(len+br+he);
16+
System.out.println("The Perimeter is : "+pr);
17+
}
18+
19+
public static void main(String[] argv) {
20+
System.out.println("Enter the Lenght, Breadth, Height : ");
21+
Scanner le = new Scanner(System.in);
22+
Cuboid cc = new Cuboid();
23+
cc.len = le.nextInt();
24+
cc.br = le.nextInt();
25+
cc.he = le.nextInt();
26+
cc.area();
27+
cc.perimeter();
28+
}
29+
}

Cuboid1.java

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package JAVACTOOOD;
2+
3+
public class Cuboid1 {
4+
public double volume(double l, double h, double b) {
5+
return l*b*h;
6+
}
7+
}

Cuboiddemo.java

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package JAVACTOOOD;
2+
3+
import java.util.Scanner;
4+
5+
public class Cuboiddemo {
6+
7+
public static void main(String[] args) {
8+
// TODO Auto-generated method stub
9+
Cuboid1 cub = new Cuboid1();
10+
Scanner sc = new Scanner(System.in);
11+
System.out.println("Enter L, B, H : ");
12+
double l = sc.nextDouble();
13+
double b = sc.nextDouble();
14+
double h = sc.nextDouble();
15+
System.out.println("The Volume is : "+cub.volume(l, h, b));
16+
sc.close();
17+
}
18+
}

Datatypes.java

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package JAVACTOOOD;
2+
3+
public class Datatypes {
4+
public static void main(String[] argv) {
5+
int value = 10;
6+
int value2 = 20;
7+
int sum = value + value2;
8+
int product = value * value2;
9+
int remain = value % value2;
10+
float div = value/value2;
11+
System.out.println("The Int1 Value is : "+value);
12+
System.out.println("The Int2 Value is : "+value2);
13+
System.out.println("The Sum is : "+sum);
14+
System.out.println("The Product is : "+product);
15+
System.out.println("The Modulus is : "+remain);
16+
System.out.println("The Division is : "+div);
17+
}
18+
}

Demo.java

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package p2;
2+
3+
import p1.Checker;
4+
import p1.DisplayAll;
5+
import p1.Utility;
6+
import java.util.Scanner;
7+
8+
public class Demo {
9+
public static void main(String[] args) {
10+
boolean shouldRun = true;
11+
Checker check = new Checker();
12+
DisplayAll all = new DisplayAll();
13+
Utility utili = new Utility();
14+
Scanner refchoice = new Scanner(System.in);
15+
16+
while(shouldRun) {
17+
System.out.println("[1]Check Armstrong [2]Check Palindrome [3]Print Reverse [4]Display Palindrome [5]Display Armstrong [6]Exit");
18+
System.out.println("Enter your Choice : ");
19+
int choice = refchoice.nextInt();
20+
switch(choice) {
21+
case 1:
22+
System.out.println("Enter the Num : ");
23+
Scanner Armref = new Scanner(System.in);
24+
int checkarm = Armref.nextInt();
25+
check.checkArmstrong(checkarm);
26+
break;
27+
28+
case 2:
29+
System.out.println("Enter the Num : ");
30+
Scanner palref = new Scanner(System.in);
31+
int checkpal = palref.nextInt();
32+
System.out.println(check.isPalindrome(checkpal));
33+
break;
34+
35+
case 3:
36+
System.out.println("Enter the Num : ");
37+
Scanner palrev = new Scanner(System.in);
38+
int palreve = palrev.nextInt();
39+
System.out.println(utili.Reverse(palreve));
40+
break;
41+
42+
case 4:
43+
System.out.println("Enter the Num : ");
44+
Scanner revpal = new Scanner(System.in);
45+
int pal = revpal.nextInt();
46+
all.DisplayPalindrome(pal);
47+
break;
48+
49+
case 5:
50+
System.out.println("Enter the Num : ");
51+
Scanner armall = new Scanner(System.in);
52+
int allarm = armall.nextInt();
53+
all.DisplayPalindrome(allarm);
54+
break;
55+
56+
case 6:
57+
System.out.println("Thank You");
58+
shouldRun=false;
59+
break;
60+
61+
default:
62+
System.out.println("Enter the correct Value : ");
63+
break;
64+
}
65+
66+
}
67+
68+
refchoice.close();
69+
}
70+
}

DisplayAll.java

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package p1;
2+
3+
public class DisplayAll {
4+
static int num;
5+
public void DisplayPalindrome(int n) {
6+
System.out.println("The Numbers are : ");
7+
Checker ch = new Checker();
8+
for(int i = 0; i <= n; i++) {
9+
if(ch.isPalindrome(i) == true) {
10+
System.out.println(i);
11+
}
12+
}
13+
}
14+
15+
public void displayArmstrong(int n) {
16+
System.out.println("The Numbers are : ");
17+
for(int i = 0; i <= n; i++) {
18+
int count = 0;
19+
int sum = 0;
20+
int temp = i;
21+
while(temp > 0) {
22+
temp = temp / 10;
23+
count++;
24+
}
25+
if(count >= 2) {
26+
temp = i;
27+
while(temp > 0) {
28+
int r = temp % 10;
29+
sum = sum + (r*r*r);
30+
}
31+
if(sum == i) {
32+
System.out.println(i);
33+
}
34+
}
35+
else {
36+
System.out.println(i);
37+
}
38+
}
39+
}
40+
}

Exception.java

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package JAVACTOOOD;
2+
3+
import java.util.Scanner;
4+
5+
public class Exception {
6+
Scanner sc = new Scanner(System.in);
7+
System.out.println("Enter A and B : ");
8+
int a = sc.nextInt();
9+
int b = sc.nextInt();
10+
try{
11+
System.out.println("Addition is : "+(a+b));
12+
}
13+
catch(ArithmeticException e){
14+
System.out.println("EXception: "+e.getMessage());
15+
}
16+
System.out.println("Multiplication is : "+(a*b));
17+
System.out.println("Division is : ",+(a/b));
18+
System.out.println("Modulo is : "+(a%b));
19+
sc.close();
20+
}

0 commit comments

Comments
 (0)