Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions AreaOfCircle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.util.Scanner;

class AreaOfCircle
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
System.out.print("Enter the radius of circle: ");
int r = s.nextInt();
s.close();

System.out.println("The Area of Circle is = "+ area(r));

}

public static float area(int r)
{
return 3.14f*(r*r);
}


}
50 changes: 50 additions & 0 deletions Armstrong.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import java.util.Scanner;


class Armstrong
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);

// System.out.println("Enter the number of digits: ");
// int len = s.nextInt();

System.out.println("Enter a Number to check: ");
int n = s.nextInt();
int str = n;
int str1 = n;
//len = String.valueOf(str).length();
int sum = 0, count=0;
s.close();

while(str1!=0){
count++;
str1/=10;
}
// System.out.println(count);

while(n!=0){

int rem = n%10;

//int cube = rem*rem*rem;
int pow = 1;
for(int i = 1; i<=count; i++)
{
pow = pow * rem;
}

sum = sum + pow;
// sum = sum + (Math.pow(rem,count));

n/=10;
}
if(str == sum)
System.out.println(str+ " is an ArmStrong Number");
else
System.out.println(str + " is Not a ArmStrong Number");


}
}
21 changes: 21 additions & 0 deletions Double.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Double
{
public static void main(String[] args)
{
System.out.println("Hello Sarwesh");

//byte to all
double i = 1.3;
byte a = (byte)i;
short b = (short)i;
int c = (int)i;
long d = (long)i;
float e = (float)i;
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);
System.out.println(e);

}
}
28 changes: 28 additions & 0 deletions EvenOdd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import java.util.Scanner;

class StrongNumber
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
System.out.println("Enter a value: ");
int n = s.nextInt();
int rem, res=1, sum=0;
s.close();

while(n!=0){

rem = n%10;

while(rem!=0){

res = res*rem;
rem--;
sum = sum + res;
}
n = n/10;


}
}
}
21 changes: 21 additions & 0 deletions Float.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Float
{
public static void main(String[] args)
{
System.out.println("Hello Sarwesh");

//byte to all
float i = 1.0f;
byte a = (byte)i;
short b = (short)i;
int c = (int)i;
long d = (long)i;
double e = (double)i;
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);
System.out.println(e);

}
}
18 changes: 18 additions & 0 deletions FunctionCall.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class FunctionCall
{
public static void main(String[] args)
{

int a = 10;
int b = 12, c=(int)display(a,b) ;
System.out.println(c);

}
public static double display(int c, int d)
{
System.out.println("Addition is");
return (c+d);
}


}
21 changes: 21 additions & 0 deletions Hello.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Hello
{
public static void main(String[] args)
{
System.out.println("Hello Sarwesh");

//byte to all
byte i = 1;
short a = (short)i;
int b = (int)i;
long c = (long)i;
float d = (float)i;
double e = (double)i;
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);
System.out.println(e);

}
}
21 changes: 21 additions & 0 deletions Int.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Int
{
public static void main(String[] args)
{
System.out.println("Hello Sarwesh");

//byte to all
int i = 1;
byte a = (byte)i;
short b = (short)i;
long c = (long)i;
float d = (float)i;
double e = (double)i;
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);
System.out.println(e);

}
}
32 changes: 32 additions & 0 deletions LL_inbuilt.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import java.util.LinkedList;
// import java.util.Stack;




public class LL_inbuilt {
public static void main(String[] args) {
LinkedList<Integer> l = new LinkedList<>();

l.add(4);
l.add(5);
l.add(6);
l.add(7);
l.add(8);
l.add(0, 1);
System.out.println(l.element());
int i;
for( i = 0; i<l.size()-1;i++)
{
System.out.print(l.get(i)+"->");
}
System.out.println(l.get(i));
// int x = l.size(),i=0;
// while(x-- !=0)
// {
// System.out.print(l.get(i++)+"->");

// }

}
}
123 changes: 123 additions & 0 deletions LinkedList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
class Node
{
int data;
Node next;
}

class Data{

Node head;


public void insert(int data)
{

Node node = new Node();

node.data = data;
node.next = null;



if(head == null)
{
head = node;
}
else
{
Node temp = head;

while(temp.next!=null)
{
temp = temp.next;
}
temp.next = node;
}
}

public void insertBeg(int data)
{
Node node = new Node();
node.data = data;
// node.next = null;

node.next = head;
head = node;
}

public void insertAfter(int data, int loc)
{
Node node = new Node();
node.data = data;

Node temp = head;

if(loc == 0)
{
insertBeg(data);
}
else{
for (int i = 0; i <loc-1; i++) {
temp = temp.next;
}
node.next = temp.next;
temp.next = node;
}
}

public void deleteAt(int index)
{
Node n = head;
if(index == 0)
{
head = head.next;
}
else{
for (int i = 1; i <index; i++) {
n = n.next;
}
Node n1 = null;
n1 = n.next;
n.next = n1.next;
}
}


public void show(){
Node node = head;

while(node.next!=null)
{
System.out.print(node.data+"->");
node = node.next;
}
System.out.println(node.data);
}
}


public class LinkedList {

public static void main(String[] args) {
Data d = new Data();

d.insert(1);
d.insert(2);
d.insert(3);
d.insert(4);
d.insert(5);
d.insert(6);
d.insert(7);
// d.insertBeg(12);
// d.insertBeg(13);
// d.insertAfter(14, 2);
// d.insertAfter(15, 0);
// d.insertAfter(155, 4);
d.deleteAt(2);
d.deleteAt(0);


d.show();
}

}
22 changes: 22 additions & 0 deletions LocalVariables.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class LocalVariables
{
static int i;
static double d = 20.98;
public static void main(String[] args)
{
int a = 20; //local variable doesn't have a default value

System.out.println(i);
System.out.println(a);
System.out.println(d);
demo(a);

}

public static void demo(int a)
{
System.out.println(a);
System.out.println(d);
}

}
Loading