Skip to content

Commit b0a54d0

Browse files
authored
Uploaded Example Folder
1 parent e60814b commit b0a54d0

38 files changed

+1971
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package Examples;
2+
3+
import pack.Add;
4+
import pack.Factorial;
5+
6+
public class Add_Factorial_usingPackages {
7+
public static void main(String args[])
8+
{
9+
int a=5,b=9,c=5;
10+
11+
Add obj = new Add(a,b);
12+
Factorial obj2 = new Factorial(c);
13+
14+
obj.show();
15+
obj2.show();
16+
}
17+
}

Examples/Add_IntString.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package Examples;
2+
3+
import java.util.Scanner;
4+
5+
public class Add_IntString {
6+
public static void main (String[] args)
7+
{
8+
int Int;
9+
String str = null;
10+
11+
Scanner input = new Scanner(System.in);
12+
13+
System.out.print("Enter Integer:");
14+
Int = input.nextInt();
15+
16+
System.out.println(addition(Int,str)+ " = Rank ");
17+
18+
}
19+
20+
public static String addition(int Int, String str)
21+
{
22+
str = "";
23+
String st= str+Int;
24+
return st;
25+
}
26+
}

Examples/Add_SquareMatrices.java

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package Examples;
2+
3+
import java.util.Scanner;
4+
public class Add_SquareMatrices {
5+
public static void main(String args[])
6+
{
7+
int i,j;
8+
9+
int add[][] = new int[3][3];
10+
int a[ ][ ] = new int[3][3];
11+
int b[ ][ ] = new int[3][3];
12+
13+
Scanner sc = new Scanner(System.in);
14+
15+
System.out.println("Enter first 3X3 matrix is :");
16+
for(i=0;i<3;i++)
17+
{
18+
for(j=0;j<3;j++)
19+
a[i][j] = sc.nextInt();
20+
}
21+
22+
System.out.println("Enter second 3X3 matrix is :");
23+
for(i=0;i<3;i++)
24+
{
25+
for(j=0;j<3;j++)
26+
b[i][j] = sc.nextInt();
27+
}
28+
29+
System.out.println("\nThe first 3X3 matrix is : ");
30+
for(i=0;i<3;i++)
31+
{
32+
for(j=0;j<3;j++)
33+
System.out.print(a[i][j]+"\t");
34+
System.out.println(" ");
35+
}
36+
37+
38+
System.out.println("\nThe second 3X3 matrix is : ");
39+
for(i=0;i<3;i++)
40+
{
41+
for(j=0;j<3;j++)
42+
System.out.print(b[i][j]+"\t");
43+
System.out.println(" ");
44+
}
45+
46+
System.out.println(" ");
47+
for(i=0;i<3;i++)
48+
{
49+
for(j=0;j<3;j++)
50+
add[i][j] = a[i][j] + b[i][j];
51+
}
52+
53+
System.out.println("The resultant addition 3X3 matrix is :") ;
54+
for(i=0;i<3;i++)
55+
{
56+
for(j=0;j<3;j++)
57+
System.out.print(add[i][j]+"\t");
58+
System.out.println(" ");
59+
}
60+
61+
}
62+
}

Examples/AreaOf_usingMethod.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package Examples;
2+
3+
import java.util.Scanner;
4+
public class AreaOf_usingMethod {
5+
public static void main (String[] args)
6+
{
7+
float r;
8+
int a,l;
9+
double h,b;
10+
11+
System.out.print("Enter Radius of circle:");
12+
Scanner input = new Scanner(System.in);
13+
r = input.nextFloat();
14+
System.out.println("Area of Circle= "+area(r,3.142f));
15+
16+
System.out.print("\nEnter Height of the Triangle: ");
17+
h=input.nextDouble();
18+
System.out.print("Enter Base of the Triangle: ");
19+
b=input.nextDouble();
20+
System.out.println("Area of Triangle= "+area(h,b));
21+
22+
System.out.print("\nEnter length of the rectangle:");
23+
l = input.nextInt();
24+
System.out.print("Enter width of the rectangle:");
25+
a = input.nextInt();
26+
System.out.println("Area of Rectangle= "+area(a,l));
27+
}
28+
29+
public static float area(float a,float pi)
30+
{
31+
float ar = pi*a*a;
32+
return ar;
33+
}
34+
35+
public static double area(double h,double b)
36+
{
37+
double ar = h*b/2;
38+
return ar;
39+
}
40+
41+
public static int area(int a, int l)
42+
{
43+
int x = a*l;
44+
return x;
45+
}
46+
}

Examples/Areaof.java

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package Examples;
2+
3+
import java.util.*;
4+
public class Areaof
5+
{
6+
public static void main(String args[])
7+
{
8+
int s;
9+
double r, w, h, b;
10+
float l;
11+
12+
Scanner sc = new Scanner(System.in);
13+
14+
System.out.print("Enter Radius of the Circle: ");
15+
r=sc.nextDouble();
16+
Area obj = new Area(r);
17+
18+
System.out.print("\nEnter Width of the Rectangle: ");
19+
w=sc.nextDouble();
20+
System.out.print("Enter Lenght of the Rectangle: ");
21+
l=sc.nextFloat();
22+
Area obj2 = new Area(w,l);
23+
24+
System.out.print("\nEnter Height of the Triangle: ");
25+
h=sc.nextDouble();
26+
System.out.print("Enter Base of the Triangle: ");
27+
b=sc.nextDouble();
28+
Area obj1 = new Area(h,b);
29+
30+
System.out.print("\nEnter Side of the Square: ");
31+
s=sc.nextInt();
32+
Area obj4 = new Area(s);
33+
}
34+
}
35+
36+
class Area
37+
{
38+
int side;
39+
double radius,lenght,width,height,base;
40+
final double pi=3.14;
41+
42+
Area(double r)
43+
{
44+
radius = r;
45+
double Area = pi*radius*radius;
46+
System.out.println("Area of the CIRCLE: "+Area);
47+
}
48+
49+
Area(double w,float l)
50+
{
51+
lenght = l;
52+
width = w;
53+
double Area2 = w*l;
54+
System.out.println("Area of the RECTANGLE: "+Area2);
55+
}
56+
57+
Area(double h, double b)
58+
{
59+
height = h;
60+
base = b;
61+
double Area3 = (h*b)/2;
62+
System.out.println("Area of the TRIANGLE: "+Area3);
63+
}
64+
65+
Area(int s)
66+
{
67+
side = s;
68+
int Area4 = side*side;
69+
System.out.println("Area of the SQUARE: "+Area4);
70+
}
71+
}
72+
73+
// Method 2:
74+
/* public static void main(String args[])
75+
{
76+
Scanner sc = new Scanner(System.in);
77+
Area obj = new Area();
78+
79+
System.out.print("Enter Radius of the Circle: ");
80+
double r=sc.nextDouble();
81+
82+
obj.Radius(r);
83+
obj.CalcArea();
84+
obj.displayArea();
85+
}
86+
}
87+
class Area
88+
{
89+
double radius, area;
90+
final double pi=3.14;
91+
92+
void Radius(double r)
93+
{
94+
radius =r;
95+
}
96+
97+
void CalcArea()
98+
{
99+
area = pi*radius*radius;
100+
}
101+
102+
void displayArea()
103+
{
104+
System.out.println("Area of the Circle is: "+area);
105+
}
106+
} */
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package Examples;
2+
3+
import java.util.*;
4+
class Account
5+
{
6+
int account_no;
7+
String name;
8+
float amount;
9+
10+
void insert(int a,String n, float amt)
11+
{
12+
account_no = a;
13+
name = n;
14+
amount = amt;
15+
}
16+
void deposit(float amt)
17+
{
18+
amount += amt;
19+
System.out.println(amt+" Deposited");
20+
}
21+
22+
void withdraw(float amt)
23+
{
24+
if(amount < amt)
25+
System.out.println("Insufficient Balance");
26+
else
27+
{
28+
amount -= amt;
29+
System.out.println(amt+" Withdrawn");
30+
}
31+
}
32+
33+
void checkBalance()
34+
{
35+
System.out.println("Total Balance: "+amount);
36+
}
37+
38+
void display()
39+
{
40+
System.out.println("\nAccount Number : "+account_no);
41+
System.out.println("Customer Name : "+name);
42+
System.out.println("Customer Amount: "+amount);
43+
}
44+
}
45+
46+
public class BankingSystem_Workingdemo
47+
{
48+
public static void main(String args[])
49+
{
50+
int account_no;
51+
String name;
52+
float amount;
53+
54+
Scanner sc = new Scanner(System.in);
55+
Account a1 = new Account();
56+
57+
System.out.print("Enter Account number: ");
58+
account_no =sc.nextInt();
59+
60+
System.out.print("\nEnter Customer name: ");
61+
name =sc.next();
62+
63+
System.out.print("\nEnter Customer amount: ");
64+
amount =sc.nextFloat();
65+
66+
a1.insert(account_no,name,amount);
67+
a1.display();
68+
a1.checkBalance();
69+
70+
System.out.print("\nEnter Amount to be Deposited: ");
71+
float dep_amount =sc.nextFloat();
72+
a1.deposit(dep_amount);
73+
a1.checkBalance();
74+
75+
System.out.print("\nEnter Amount to be Withdrawn: ");
76+
float wit_amount =sc.nextFloat();
77+
a1.withdraw(wit_amount);
78+
a1.checkBalance();
79+
80+
System.out.println("\n THANK YOU!!");
81+
}
82+
}

Examples/BiggestNumberamong3int.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package Examples;
2+
3+
import java.util.*;
4+
5+
public class BiggestNumberamong3int
6+
{
7+
8+
public static void main(String[] args)
9+
{
10+
int x=0, y=0, z=0, largest;
11+
Scanner s = new Scanner(System.in);
12+
System.out.print("Enter the first number:");
13+
x = s.nextInt();
14+
System.out.print("Enter the second number:");
15+
y = s.nextInt();
16+
System.out.print("Enter the third number:");
17+
z = s.nextInt();
18+
largest = x > (y>z ? y:z) ? x:(y>z? y:z) ;
19+
System.out.print("The lagerst number is "+largest);
20+
}
21+
22+
}

0 commit comments

Comments
 (0)