Skip to main content

JAVA PRACTICAL ASSIGNMENT

                                               

                                                      JAVA ASSIGNMENT NO-4



1)wap to input a no and check it is a prime or not


import java .io.*;
class prime
{
 int n;
 prime(int t)
 {
 n=t;
 }
void cal()
 {
int i,c=0;
for(i=2;i<n;i++)
  {
 if(n%i==0)
   {
    c=c+1;
    break;
   }
  }
 if(c==1)
 System.out.println("not prime");
 else
 System.out.println("prime");
 }
}
class cont
{
public static void main(String arg[])
{
prime s=new prime(7);
s.cal();
}
}



2)wap to iput a no and check it is automorphic or not


import java .io.*;
class prime
{
 int n,y,g;
prime(int t)
 {
n=t;
//storing value of n in y
y=n;
int i=1,c=0,d;
while(n>0)
{
d=n%10;
if(d>1)
{
c=d*i; //here we get the value of first no of digit*(0) according to no of digit
}
n=n/10;
i=i*10; //every time multiply by 10
}
g=(y-c)*(y-c);//ex (749-700) we wil get the no leaving first no
if(g==y)  //checking both value

 System.out.println("no is automorphic");
else

 System.out.println("not automorphic");
}
}
class atmor
{
public static void main(String arg[])
{
int d;
prime s=new prime(25);
}
}



3)wap to input a no and check it is Armstrong or not

import java .io.*;
class prime
{
 int n,b;
 prime(int t)
 {
 n=t;
 }
void cal()
 {
int i,f=0,d,a;
a=n;
while(n>0)
{
b=n%10;
f=f+b*b*b;
n=n/10;
}
 if(f==a)
 System.out.println("armstrong");
 else
 System.out.println("no is not armstrong");
 }
}
class arm
{
public static void main(String arg[])
{
prime s=new prime(15);
s.cal();
}
}




4)wap to find sun of digit until it is beacme a single digit

import java .io.*;
class prime
{
 int n,b;
 prime(int t)
 {
 n=t;
 }
void cal()
 {
int i,f=0,d,a;
while(n>1)
{
b=n%10;
f=f+b;
n=n/10;
}

 System.out.println("answer is="+f);
 }
}
class single
{
public static void main(String arg[])
{
prime s=new prime(115);
s.cal();
}
}



5)wap to input a no and find the biggest digit

import java .io.*;
class prime
{
 int n,b;
 prime(int t)
 {
 n=t;
 }
void cal()
 {
int f=0,max=0;
while(n>1)
{
b=n%10;
if(b>max)
max=b;
n=n/10;
}

 System.out.println("max is="+max);
 }
}
class last
{
public static void main(String arg[])
{
prime s=new prime(195);
s.cal();
}
}







                                                     JAVA ASSIGNMENT NO-1




1)WAP to display ur name

class name
{
public static void main(String arg[])
{
System.out.print("may name is manish");
}
}

2)WAP to disply int,char,float,double & string.


class int1
{
public static void main(String arg[])
{
int a;
double b;
String s;
float f;
char ch;
a=5;
ch='m';
f=0.1f;
b=12.566;
System.out.println("int is="+a);
System.out.println("float is="+f);
System.out.println("double is="+b);
System.out.println("char="+ch);
System.out.println("string is="+"manish");
}
}


3)WAP to enter 2 nos & find their sum, subtraction, multiplication,division.


import java .io.*;
class rate
{
int a,b,c;
 void input()
{
  DataInputStream br=new DataInputStream(System.in);
  System.out.println("enter two number");
  try
{
  a=Integer.parseInt(br.readLine());
  b=Integer.parseInt(br.readLine());
}
catch(Exception e)
{
}
}
void add()
{
c=a+b;
 System.out.println("sum="+c);
}
void sub()
{
c=a-b;
 System.out.println("sub="+c);
}
void mul()
{
c=a*b;
 System.out.println("mul="+c);
}
void div()
{
c=a/b;
 System.out.println("div="+c);
}
}
class cal
{
public static void main(String arg[])
{
rate t=new rate();
t.input();
t.add();
t.sub();
t.mul();
t.div();
}
}




4)WAP to enter 2 nos & swap them.



import java .io.*;
class rate
{
int a,b,c;
 void input()
{
  DataInputStream br=new DataInputStream(System.in);
  System.out.println("enter two number");
  try
{
  a=Integer.parseInt(br.readLine());
  b=Integer.parseInt(br.readLine());
}
catch(Exception e)
{
}
}
void cal()
{
c=a;
a=b;
b=c;
 System.out.println("after swap a="+a +"and b=" +b);
}
}
class swap
{
public static void main(String arg[])
{
rate t=new rate();
t.input();
t.cal();
}
}





5)WAP to enter 2 nos and swap them without using 3rd variable.



import java .io.*;
class rate
{
int a,b,c;
 void input()
{
  DataInputStream br=new DataInputStream(System.in);
  System.out.println("enter two number");
  try
{
  a=Integer.parseInt(br.readLine());
  b=Integer.parseInt(br.readLine());
}
catch(Exception e)
{
}
}
void cal()
{
a=a+b;
b=a-b;
a=a-b;
 System.out.println("after swap a="+a +"and b=" +b);
}
}
class swap1
{
public static void main(String arg[])
{
rate t=new rate();
t.input();
t.cal();
}
}







                                                    JAVA ASSIGNMENT N0-2





1)WAP TO FIND THE TEMP IN CELSIUS


import java .io.*;
class temp
{
int f,c;
 void input()
{
  DataInputStream br=new DataInputStream(System.in);
  System.out.println("enter the temprature");
  try
{
  f=Integer.parseInt(br.readLine());
}
catch(Exception e)
{
}
}
void cal()
{
c=(f-32)*5/9;
 System.out.println("temprature in celsius is="+c);
}
}
class celsius
{
public static void main(String arg[])
{
temp t=new temp();
t.input();
t.cal();
}
}




2)WAP TO FIND AREA OF CIRCLE


import java .io.*;
class area
{
int r;
double a;
 void input()
{
  DataInputStream br=new DataInputStream(System.in);
  System.out.println("enter the radius");
  try
{
  r=Integer.parseInt(br.readLine());
}
catch(Exception e)
{
}
}
void cal()
{
a=3.14*r*r;
 System.out.println("temprature in celsius is="+a);
}
}
class circle
{
public static void main(String arg[])
{
area t=new area();
t.input();
t.cal();
}
}



3)WAP TO CALCULATE SIMPLE INTEREST


import java .io.*;
class rate
{
int p,r,t;
double a;
 void input()
{
  DataInputStream br=new DataInputStream(System.in);
  System.out.println("enter the principal,rate and time");
  try
{
  p=Integer.parseInt(br.readLine());
  r=Integer.parseInt(br.readLine());
  t=Integer.parseInt(br.readLine());
}
catch(Exception e)
{
}
}
void cal()
{
a=(p*r*t)/100;
 System.out.println("temprature in celsius is="+a);
}
}
class si
{
public static void main(String arg[])
{
rate t=new rate();
t.input();
t.cal();
}
}




4)wap to find roots of qudratic equation


import java .io.*;
class rate
{
int a,b,c;
double d,r1,r2;
 void input()
{
  DataInputStream br=new DataInputStream(System.in);
  System.out.println("a,b and c");
  try
{
  a=Integer.parseInt(br.readLine());
  b=Integer.parseInt(br.readLine());
  c=Integer.parseInt(br.readLine());
}
catch(Exception e)
{
}
}
void cal()
{
d=b*b-(4*a*c);
r1=(-b+(Math.sqrt(d)))/(2*a);
r2=(-b-(Math.sqrt(d)))/(2*a);
 System.out.println("root are ="+r1);
 System.out.println("root are ="+r2);
}
}
class root
{
public static void main(String arg[])
{
rate t=new rate();
t.input();
t.cal();
}
}




5)wap to find area of equrateral triangle


import java .io.*;
class area
{
int s;
double a;
 void input()
{
  DataInputStream br=new DataInputStream(System.in);
  System.out.println("enter the side");
  try
{
  s=Integer.parseInt(br.readLine());
}
catch(Exception e)
{
}
}
void cal()
{
a=((Math.sqrt(3))/4)*s*s;
 System.out.println("temprature in celsius is="+a);
}
}
class triangle
{
public static void main(String arg[])
{
area t=new area();
t.input();
t.cal();
}
}








                                         COLLEGE JAVA ASSIGNMENT NO -3



1) WAP TO ENTER TWO NO AND DISPLAY WHICH ONE IS GREATER




import java .io.*;

class greater

{

int a,b;

void input()

{

DataInputStream br=new DataInputStream(System.in);

System.out.println("enter two no");

try

{

a=Integer.parseInt(br.readLine());

b=Integer.parseInt(br.readLine());

}

catch(Exception e)

{

}

}

void cal()

{

if(a>b)

System.out.println("greater no is="+a);

else

System.out.println("greater no is ="+b);

}

}

class astwo

{

public static void main(String arg[])

{

greater t=new greater();

t.input();

t.cal();

}

}



2) WAP TO ENTER A NO AND CHECK IT EVEN OR ODD




import java.io.*;

class even

{

int a;

void input()

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.println("enter two no");

a=Integer.parseInt(br.readLine());

}

void check()

{

if(a%2==0)

System.out.println("even");

else

System.out.println("odd");

}

}

class odd

{

public static void main(String arg[])

{

even c=new even();

c.input();

c.check();

}

}


3) WAP TO ENTER 3 NUMBER AND FIND THE LARGEST AMONG THEM




import java .io.*;

class max

{

int a,b,c;

void input()

{
DataInputStream br=new DataInputStream(System.in);

System.out.println("enter three no");

try

{

a=Integer.parseInt(br.readLine());

b=Integer.parseInt(br.readLine());

c=Integer.parseInt(br.readLine());

}

catch(Exception e)

{

}

}

void cal()

{

if((a>b) && (a>c))

System.out.println("greater no is="+a);

if((b>a) && (b>c))

System.out.println("greater no is ="+b);

else

System.out.println("greater no is ="+c);

}

}

class max3

{

public static void main(String arg[])

{

max t=new max();

t.input();

t.cal();

}

}



4) WAP TO CALCULATE ELECTRICTY BILL READ THE STARTING AND

ENDING METER READING NO OF UNIT CONSUME

1.200-500 RATE IS Rs3.50/UNIT

2.100-200 RATE IS Rs2.50/UNIT

3.LESS THAN 200 Rs1.50/UNIT



import java .io.*;

class elect

{

int a;

double price;

void input()

{

DataInputStream br=new DataInputStream(System.in);

System.out.println("enter the unit consume");

try

{

a=Integer.parseInt(br.readLine());

}

catch(Exception e)

{

}

}

void cal()

{

if((a>200) && (a<500))

{

price=3.50*a;

System.out.println("total electricity bill is="+price);

}

if((a>100) && (a<200))

{

price=2.50*a;
System.out.println("total electricity bill is="+price);

}

if(a<100)

{

price=1.50*a;

System.out.println("total electricity bill is="+price);

}

}

}

class bill

{

public static void main(String arg[])

{

elect t=new elect();

t.input();

t.cal();

}

}



5) WAP TO ENTER THE GENDER AND SALARY OF EMPLOYEE AND DISPLAY

HIS GROSS AND NET SALARY ACCORING TO THE GIVEN CONDITION

1.IF GENDER IS FEMALE AND SAL>10000

A.HRA=15%

B.DA=10%

C.PF=10%

2.IF GENDER IS MALE AND SAL>5000

A.HRA=20%

B.DA=15%

C.PF=10%

3.FOR OTHERS

A.HRA=10%

B.DA=9%

C.PF=8%






import java .io.*;

class basic

{

int b;

double da,pf,hra,ns,gs;

void input()

{

DataInputStream br=new DataInputStream(System.in);

try

{

System.out.println("enter your basic salary");

b=Integer.parseInt(br.readLine());

System.out.println("enter your gender");

a=(char)br.read();

}
catch(Exception e)

{

}

}

void cal()

{


if((a=='m') && (b>5000))

{

hra=(20*b)/100;

da=(15*b)/100;

pf=(10*b)/100;

gs=hra+da+pf+b;

ns=gs-pf;

System.out.println("Net salary="+ns);

}

else if((a=='f') && (b>10000))

{

hra=(15*b)/100;

da=(10*b)/100;

pf=(8*b)/100;

gs=hra+da+pf+b;

ns=gs-pf;

System.out.println("Net salary="+ns);

}

else

{

hra=(10*b)/100;

da=(9*b)/100;

pf=(8*b)/100;

gs=hra+da+pf+b;

ns=gs-pf;

System.out.println("Net salary="+ns);

}


}

}

class sal

{

public static void main(String arg[])

{

basic t=new basic();

t.input();

t.cal();

}

}

THANKS FOR VISIT IF YOUR HAVE ANY QUERY REGARDING OUTPUT CONTACT ME
MANISH RAJ
9576253532











Comments

Popular posts from this blog

Death of a Star! in Bollywood

When I was flipping through my Diary 2002 the other day, my jottings about Monal’s tragic end beckoned me and brought to my mind a host of awesome nostalgic thoughts. I had a feeling of déjà vu as the dead artist again touched a chord in my heart. How would emotionally deplete artists behave when driven to wall? [Read on…] Monal, a starlet from Bollywood, hung herself to death on the Tamil New Year’s Day. A strange quirk of fate played havoc with her life, putting off her promising career of becoming an icon in the Kollywood. TV visuals showed her sleeping eternally on a bier; she was a feast to flies that were swarming her lissome body … a body that set fire to the hearts of thousands of her fans. Monal’s premature death moved me to a great extent not because she was one of the upcoming actors of the Kollywood and a diva for whom the tinsel world plumped rather madly, but because it set me thinking as to what led the young actor to kill herself savagely in the middle of her

11-awesome-diwali-lighting-decoration-ideas

Beautiful Flower Lights On Water Diwali Decoration Ideas Picture Beautiful Hanging Lighting Lanterns Diwali Decoration Beautiful Lighting Decoration For Diwali Beautiful Lighting Lamps Decoration Cool Diwali Lighting Decoration Ideas Diwali Lighting Decoration Picture Diwali Lighting Decoration Ideas Elegant Hanging Lighting Lamp Decoration Glass Bottles Hanging Lighting Lamps Diwali Decoration Hanging Beautiful Lighting Kandil Diwali Decoration Photo Shubh Labh Lighting Decoration For Diwali

Ssc combined graduate level exam syllabus and exam detail

q Tier-I of the Examination: General Intelligence & Reasoning : It would include questions of both verbal and non-verbal type. This component may include questions on analogies, similarities and differences, space visualization, spatial orientation, problem solving, analysis, judgment, decision making, visual memory, discrimination, observation, relationship concepts, arithmetical reasoning and figural classification, arithmetic number series, non-verbal series, coding and decoding, statement conclusion, syllogistic reasoning etc. The topics are, Semantic Analogy, Symbolic/Number Analogy, Figural Analogy, Semantic Classification, Symbolic/Number Classification, Figural Classification, Semantic Series, Number Series, Figural Series, Problem Solving, Word Building, Coding & de-coding, Numerical Operations, symbolic Operations, Trends, Space Orientation, Space Visualization, Venn Diagrams, Drawing inferences, Punched hole/pattern –folding & unfolding, Figural Pattern – folding