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

27 Simple mehndi designs for hands for Karwa Chauth

The most  simple mehndi designs for hands  for Karwa Chauth 2014 Karwa Chauth  is around the corner and I am so excited about getting mehndi done! This time I plan to go with a simple yet quirky design. Don’t want my hands full, however it needs to be a style statement for this year’s most awaited festival for us ladies! There are some basic categories of mehndi designs, such as Gujrati, Rajasthani, Marwari,  Arabic  and African  patterns to choose from. They have certain prominent motifs or symbols that distinguishes one from the other. I just can’t seem to stop experimenting with these styles. From  circles to squares , peacocks and paisleys , checks and dots and what not. But my all-time favorite is a simple, curling vine, of course finger tips covered with thick coating of aromatic mehndi (which is so traditional). Quirky patterns include  traditional  as well as non-traditional patterns tweaked to one’s own liking. This includ...

‘Pratyusha Didn’t Hang Herself But Instead It Was Rahul Who Did It’, Claim Pratyusha’s Friends

The Balika Vadhu actress Pratyusha Banerjee was one of the most loved TV actresses ever and her suicide has left the whole India shocked. Even though earlier also actresses have committed suicide, it won’t be wrong to say that Pratyusha had a great fan following and that’s why not only her family but the whole nation is lamenting her death. Another reason for the same is that people knew her as a bubbly girl who was full of life and such a catastrophic step was not at all expected from her. However, one after another fact has come to sight about the actress and her personal life on a regular basis and no doubt, the revelations are shocking to the core. Besides, they are making the case even more complicated. As per reports, she even made attempts of committing suicide previously twice and here again comes a shocking thing! While police claims that it is a suicide case, Pratyusha’s friends are determined to fight for her so that justice can be done. They are of the opinion tha...

Kick new song Hangover: Salman Khan’s singing stint is impressive!

The  Kick  star has lent his voice for his new song  Hangover The wait is over.  Hangover  is here! Last time, Salman Khan floored us all with his tapori stint in song  Jumme Ki Raat alongside Jacqueline Fernandez who sizzled with her sultry moves, donning a hot red lace dress. It seems along with giving us killer action sequences and  Dabangg  one liners, our very own Sallu  miyaan  can sing as well! The  Jai Ho  star’s highly anticipated singing stint in  Hangover  is finally out and we are happy to report that the Bhaijaan of B-town has certainly pleasantly surprised us all with his voice which has elements of a sexy twang and a Salman’s casual laid back back feel to it. The song on the whole is romantic, with a hint of zing added to it which makes it appealing to the ears. The tune is catchy and the lyrics are simple, which make  Hangover  a pleasant melody overall. We wonder what the video of ...