Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit e4153ca

Browse files
committed
Final commit
1 parent fe20b7e commit e4153ca

Some content is hidden

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

86 files changed

+2032
-0
lines changed

Diff for: A.java

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class A
2+
{
3+
public static void main(String arg[])
4+
{
5+
String s1="Jatin";
6+
System.out.println(s1);
7+
}
8+
}

Diff for: AbstractDemo.java

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
abstract class Shapes
2+
{ int side1,side2;
3+
void set(int s)
4+
{ side1=s;
5+
side2=0;
6+
}
7+
void set(int s1,int s2)
8+
{ side1=s1;
9+
side2=s2;
10+
}
11+
abstract void area();
12+
abstract void perimeter();
13+
}
14+
class Rectangle extends Shapes
15+
{ void area()
16+
{
17+
System.out.println("AREA OF RECTANGGLE="+(side1*side2));
18+
}
19+
void perimeter()
20+
{
21+
System.out.println("PERIMETER OF RECTANGGLE="+(2*(side1+side2)));
22+
}
23+
}
24+
class Triangle extends Shapes
25+
{ void area()
26+
{
27+
System.out.println("AREA OF TRIANGLE="+(0.5F*(side1*side2)));
28+
}
29+
void perimeter()
30+
{
31+
System.out.println("PERIMETER OF TRIANGLE="+(side1+side2+side1));
32+
}
33+
}
34+
class Square extends Shapes
35+
{ void area()
36+
{
37+
System.out.println("AREA OF SQUARE="+(side1*side1));
38+
}
39+
void perimeter()
40+
{
41+
System.out.println("PERIMETER OF SQUARE="+(4*side1));
42+
}
43+
}
44+
45+
46+
47+
class AbstractDemo
48+
{
49+
public static void main(String[] args)
50+
{
51+
Rectangle r= new Rectangle();
52+
Triangle t = new Triangle();
53+
Square s= new Square();
54+
r.set(10,20);
55+
t.set(20,30);
56+
s.set(10);
57+
r.area();
58+
r.perimeter();
59+
t.area();
60+
t.perimeter();
61+
s.area();
62+
s.perimeter();
63+
64+
65+
}
66+
}

Diff for: AppletDemo.java

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import java.applet.*;
2+
import java.awt.*;
3+
4+
/*<applet code="AppletDemo" width="500" height="500">
5+
</applet>
6+
*/
7+
public class AppletDemo extends Applet
8+
{
9+
10+
public void paint(Graphics g)
11+
{
12+
/*g.drawOval(180,180,200,200);
13+
g.drawOval(220,220,30,30);
14+
g.drawOval(300,220,30,30);
15+
g.drawArc(260,280,50,80,00,-180);*/
16+
g.drawString("A SMPLE APPLET",20,20);
17+
}
18+
}

Diff for: ArmStrong.java

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import java.io.*;
2+
class ArmStrong
3+
{
4+
void Arm()
5+
{
6+
try
7+
{
8+
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
9+
System.out.println("ENTER THE NUMBER:");
10+
int num=Integer.parseInt(br.readLine());
11+
int check=0,rem;
12+
int n=num;
13+
while(num>0)
14+
{
15+
rem=num%10;
16+
check=check+(int)Math.pow(rem,3);
17+
num=num/10;
18+
}
19+
if(check==n)
20+
System.out.println("IS AN ARMSTONG NUMBER");
21+
else
22+
System.out.println(n+" IS NOT ARMSTRONG NUMBER");
23+
24+
}
25+
catch (Exception e)
26+
{
27+
}
28+
}
29+
public static void main(String args[])
30+
{
31+
ArmStrong obj=new ArmStrong();
32+
obj.Arm();
33+
}
34+
}

Diff for: ArmStrong1.java

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import java.io.*;
2+
class ArmStrong
3+
{
4+
void Arm()
5+
{
6+
try
7+
{
8+
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
9+
System.out.println("ENTER THE NUMBER:");
10+
int num=Integer.parseInt(br.readLine());
11+
int check=0,rem;
12+
int n=num;
13+
while(num>0)
14+
{
15+
rem=num%10;
16+
check=check+(int)Math.pow(rem,3);
17+
num=num/10;
18+
}
19+
if(check==n)
20+
System.out.println("IS AN ARMSTONG NUMBER:");
21+
else
22+
System.out.println(n+"IS NOT ARMSTRONG NUMBER:");
23+
24+
}
25+
catch (Exception e)
26+
{
27+
}
28+
}
29+
public static void main(String args[])
30+
{
31+
ArmStrong obj=new ArmStrong();
32+
obj.Arm();
33+
}
34+
}

Diff for: BarGraph.java

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.applet.*;
2+
import java.awt.*;
3+
/*<applet code="BarGraph" width="1400" height="700">
4+
</applet>
5+
*/
6+
public class BarGraph extends Applet
7+
{
8+
public void paint(Graphics g)
9+
{
10+
g.drawLine(100,500,1200,500);
11+
g.fillRect(100,250,50,250);
12+
g.fillRect(150,120,50,380);
13+
g.fillRect(200,250,50,250);
14+
g.fillRect(300,180,50,320);
15+
g.fillRect(350,140,50,360);
16+
g.fillRect(400,300,50,200);
17+
g.fillRect(500,400,50,100);
18+
g.fillRect(550,350,50,150);
19+
g.fillRect(600,300,50,200);
20+
g.fillRect(700,250,50,250);
21+
g.fillRect(750,150,50,350);
22+
g.fillRect(800,350,50,150);
23+
24+
}
25+
}

Diff for: BigFactorial.java

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import java.io.*;
2+
import java.math.BigInteger;
3+
class BigFactorial
4+
{
5+
public static void main(String args[])
6+
{
7+
try
8+
{
9+
BigInteger inc=new BigInteger("1");
10+
BigInteger fact=new BigInteger("1");
11+
12+
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
13+
System.out.println("ENTER THE NUMBER");
14+
int num=Integer.parseInt(br.readLine());
15+
16+
for(int i=1;i<=num;i++)
17+
{
18+
fact=fact.multiply(inc);
19+
inc=inc.add(BigInteger.ONE);
20+
}
21+
System.out.println(num+"!="+fact);
22+
}
23+
catch (Exception e)
24+
{
25+
}
26+
}
27+
}

Diff for: BigInteger.java

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import java.math.BigInteger;
2+
3+
public class Integer
4+
{
5+
public static void main(String[] args)
6+
{
7+
8+
9+
BigInteger numberA=new BigInteger("987654321234567897855");
10+
BigInteger numberB= BigInteger.TEN;
11+
12+
numberA=numberA.add(numberB);
13+
14+
System.out.println("NumberA ="+numberA);
15+
}
16+
}

Diff for: BinaryAddition.java

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import java.io.*;
2+
import java.util.*;
3+
4+
public class BinaryAddition{
5+
6+
String addBinary(string a, string b)
7+
{
8+
String result = ""; // Initialize result
9+
int s = 0; // Initialize digit sum
10+
11+
// Travers both strings starting from last
12+
// characters
13+
int i = a.size() - 1, j = b.size() - 1;
14+
while (i >= 0 || j >= 0 || s == 1)
15+
{
16+
// Comput sum of last digits and carry
17+
s += ((i >= 0)? a[i] - '0': 0);
18+
s += ((j >= 0)? b[j] - '0': 0);
19+
20+
// If current digit sum is 1 or 3, add 1 to result
21+
result = char(s % 2 + '0') + result;
22+
23+
// Compute carry
24+
s /= 2;
25+
26+
// Move to next digits
27+
i--;
28+
j--;
29+
}
30+
return result;
31+
}
32+
33+
public static void main(String args[]){
34+
BinaryAddtion obj = new BinaryAddition();
35+
String a = "1001";
36+
String b = "1000";
37+
String ans = obj.addBinary(a,b);
38+
System.out.prinln("ANS IS:"+ ans);
39+
}
40+
41+
}
42+
43+
44+

Diff for: BinarySearch.java

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import java.io.*;
2+
class BinarySearch
3+
{ void bin(){
4+
try{
5+
int i,j,temp,low,mid,high;
6+
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
7+
System.out.println("ENTER THE VALUE OF NUM:");
8+
int num=Integer.parseInt(br.readLine());
9+
System.out.println("ENTER THE ELEMENTS OF ARRAY:");
10+
int[] array=new int[num];
11+
for(i=0;i<num;i++)
12+
{
13+
array[i]=Integer.parseInt(br.readLine());
14+
}
15+
for(i=0; i<num; i++)
16+
{ for(j=0; j<(num-i-1); j++)
17+
{ if(array[j] > array[j+1])
18+
{
19+
temp = array[j];
20+
array[j] = array[j+1];
21+
array[j+1] = temp;
22+
}
23+
}
24+
}
25+
System.out.println("SORTED ARRAY:");
26+
for(i=0;i<num;i++)
27+
{
28+
System.out.println(array[i]);
29+
}
30+
System.out.println("ENTER THE ELEMENT TO BE SEARCHED:");
31+
int search=Integer.parseInt(br.readLine());
32+
low=0;
33+
high=num-1;
34+
do{
35+
mid=(low+high)/2;
36+
if(search<array[mid])
37+
{
38+
high=mid-1;
39+
}
40+
else if(search>array[mid])
41+
{
42+
low=mid+1;
43+
}
44+
}while(search!=array[mid] && low<=high);
45+
if(search==array[mid])
46+
{ System.out.println("SEARCH SUCCESFUL");
47+
System.out.println("ELEMENT LOCATED AT:"+(mid+1));
48+
}
49+
else
50+
System.out.println("NOT FOUND");
51+
}
52+
catch (Exception e){}
53+
}//end of func
54+
55+
public static void main(String args[])
56+
{
57+
BinarySearch bs=new BinarySearch();
58+
bs.bin();
59+
}
60+
}

Diff for: BubbleSort.java

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import java.io.*;
2+
class BubbleSort
3+
{ void bin()
4+
{ try
5+
{
6+
int i,j,temp;
7+
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
8+
System.out.println("ENTER THE VALUE OF NUM:");
9+
int num=Integer.parseInt(br.readLine());
10+
System.out.println("ENTER THE ELEMENTS OF ARRAY:");
11+
int[] array=new int[num];
12+
for(i=0;i<num;i++)
13+
{
14+
array[i]=Integer.parseInt(br.readLine());
15+
}
16+
for(i=0;i<num;i++)
17+
{ for(j=0;j<(num-i-1);j++)
18+
{ if(array[j]>array[j+1])
19+
{ temp=array[j];
20+
array[j]=array[j+1];
21+
array[j+1]=temp;
22+
}
23+
}
24+
}
25+
System.out.println("SORTED ARRAY:");
26+
for(i=0;i<num;i++)
27+
{
28+
System.out.println(array[i]);
29+
}
30+
}
31+
catch (Exception e){}
32+
}
33+
public static void main(String[] args)
34+
{
35+
BubbleSort bs=new BubbleSort();
36+
bs.bin();
37+
}
38+
}

Diff for: Character.java

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Character
2+
{
3+
public static void main(String[] args)
4+
{
5+
String s="Java";
6+
int count;
7+
for(int i=1;i<=s.length();i++)
8+
{
9+
if(Character.isLetter(s.charAt(i)))
10+
count++;
11+
12+
}
13+
System.out.println("NUMBER OF CHARACTERS ARE:"+count);
14+
15+
}
16+
}

0 commit comments

Comments
 (0)