Академический Документы
Профессиональный Документы
Культура Документы
import java.util.Scanner;
class quad
{
public static void main(String args[])
{
System.out.println("NAME : SHUBHANSHU SINGH");
System.out.println("UNIVERSITY ROLL NUMBER :
1503213104"); int a,b,c,d;
double x=0,y=0;
System.out.println("enter the coefficients of quadratic equation");
Scanner in = new Scanner(System.in);
a=in.nextInt();
b=in.nextInt();
c=in.nextInt(
); d=(b*b)(4*a*c);
if(d>=0)
{
if(d>0)
{
System.out.println("roots are real and
distinct"); x=(Math.sqrt(d)-b)/(2*a);
y=-(Math.sqrt(d)+b)/(2*a);
}
else if(d==0)
{
System.out.println("roots are real and equal");
ABES Engineering
College
Sign of Faculty
with date
x=-(b(2*a));
y=x;
}
System.out.println("x1="+x);
System.out.println("x2="+y);
}
else
{
System.out.println("there are no real solutions");
}
}
}
ABES
Engineering
College
Sign of Faculty
with date
ABES
Engineering
College
Sign of Faculty
with date
import java.util.Scanner;
class fib
{
public static void main(String args[])
{
System.out.println("NAME : SHUBHANSHU SINGH");
System.out.println("UNIVERSITY ROLL NUMBER :
1503213104"); int a=0,b=1,c=0,n;
System.out.println("enter the
value of n"); Scanner in=new
Scanner(System.in);
n=in.nextInt();
n=n-2;
while(n
>0)
{
c=a+b;
a=b;
b=
c;
n--;
}
System.out.println("nth value of fibonacci sequence is "+c);
}
}
ABES
Engineering
College
Sign of Faculty
with date
ABES
Engineering
College
Sign of Faculty
with date
import java.util.Scanner;
class fibo
{
public static void main(String args[])
{
System.out.println("NAME : SHUBHANSHU SINGH");
System.out.println("UNIVERSITY ROLL NUMBER :
1503213104"); int n,f=0;
System.out.println("enter the
value of n"); Scanner in=new
Scanner(System.in);
n=in.nextInt();
f=fibonacci(n);
System.out.println("nth value of fibonacci sequence is "+f);
}
public static int fibonacci(int x)
{
if(x==1)
return 0;
else
if(x==2)
return 1;
else
return fibonacci(x-1)+fibonacci(x-2);
}
}
ABES
Engineering
College
Sign of Faculty
with date
ABES
Engineering
College
Sign of Faculty
with date
import java.util.Scanner;
class prime
{
public static void main(String args[])
{
System.out.println("NAME : SHUBHANSHU SINGH");
System.out.println("UNIVERSITY ROLL NUMBER :
1503213104"); int n,c=0,i,j;
System.out.print("enter the value
of n: "); Scanner in=new
Scanner(System.in);
n=in.nextInt();
System.out.println("First "+n+" prime
numbers are: "); for(i=1;n>0;i++)
{
c=0;
for(j=1;j<i;j++)
if(i%j==0)
c++;
if(c==1)
{
System.out.print("
"+i); n--;
}
}
}
}
ABES
Engineering
College
Sign of Faculty
with date
ABES
Engineering
College
Sign of Faculty
with date
import java.util.Scanner;
class mat
{
public static void main(String args[])
{
System.out.println("NAME : SHUBHANSHU SINGH");
System.out.println("UNIVERSITY ROLL NUMBER :
1503213104"); int i,j,k;
int
int[2][2];
[]=new
int
a[][]=new
int
b[]
int[2][2];
c[][]=new
int[2][2];
ABES Engineering
College
Sign of Faculty
with date
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
c[i][j]=0;
for(k=0;k<2;k++)
c[i][j]=c[i][j]+(a[i]
[k]*b[k][j]);
System.out.print("
"+c[i][j]);
}
System.out.println("");
}
}
}
ABES
Engineering
College
Sign of Faculty
with date
ABES
Engineering
College
Sign of Faculty
with date
class rect
{
public static void main(String arg[])
{
System.out.println("NAME : SHUBHANSHU SINGH");
System.out.println("UNIVERSITY ROLL NUMBER : 1503213104");
Rectangle rect1 = new Rectangle(9,5);
System.out.println("Area1 = " + rect1.getArea());
Rectangle rect2 = new Rectangle(8,4);
System.out.println("Area2 = " + rect2.getArea());
}
}
class Rectangle
{
int
length;
int
breadth;
int getArea()
{
return length * breadth;
}
ABES Engineering
College
Sign of Faculty
with date
ABES
Engineering
College
Sign of Faculty
with date
class Rectangle
{
int
length;
int
breadth;
Rectangle(int l,int b)
{
length=l;
breadth=b;
}
void Area(int i)
{
int area;
area=length*brea
dth ;
ABES Engineering
College
Sign of Faculty
with date
ABES
Engineering
College
Sign of Faculty
with date
class thread
{
public static void main (String[] args)
{
System.out.println("NAME : SHUBHANSHU SINGH");
System.out.println("UNIVERSITY ROLL NUMBER : 1503213104");
A ob1=new A();
ob1.run();
B ob2=new
B();
ob2.run();
}
}
class A extends Thread
{
public void run()
{
System.out.println("Hello");
}
}
class B extends Thread
{
public void run()
{
System.out.println("ABES");
}
}
ABES
Engineering
College
Sign of Faculty
with date
ABES
Engineering
College
Sign of Faculty
with date