Comp Project - Copy

download Comp Project - Copy

of 62

Transcript of Comp Project - Copy

  • 7/28/2019 Comp Project - Copy

    1/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah1

    Ques1:- PROGRAM TO FIND THE LOWEST EVEN AND HIGHEST ODD?

    // PROGRAM TO FIND THE LOWEST EVEN AND HIGHEST ODDimport java.io.*;

    import java.lang.*;

    class prg28

    {public void q28()throws IOException

    {BufferedReader input=new BufferedReader(new InputStreamReader(System.in));

    int n=0,i=0,ho=0,le=0;

    for(i=1;in))

    le=n;

    }

    else

    { if(ho

  • 7/28/2019 Comp Project - Copy

    2/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah2

    System.out.println("\n Enter elements for first array");

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    3/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah3

    }

    System.out.println("\n\n All duplicates elements");for(i=0;i

  • 7/28/2019 Comp Project - Copy

    4/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah4

    }

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    5/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah5

    work()

    { a=0;b=0;

    c=0.0;

    }

    double add(int a,int b)

    { c=(double)a+b;

    return c;

    }

    }

    class prg25{ public void q25()throws IOException

    { work obwork=new work();

    BufferedReader input=new BufferedReader(new

    InputStreamReader(System.in));

    int x=0,y=0;

    double sum=0.0;

    System.out.println("Enter first value =");

    x=Integer.parseInt(input.readLine());

    System.out.println("Enter second value =");y=Integer.parseInt(input.readLine());

    sum=obwork.add(x,y);

    System.out.println("Sum of two numbers =" +sum);

    }

    }

    Variable name type use

    a int To store value

    b int To store value

    c int To store value

    Ques5:- program to use constructor with a class to calculate netpay?

    // program to use constructor with a class to calculate netpay

    import java.io.*;

    import java.lang.*;

    class employee

    { public double bpay;

    employee(double bp) // use of construtor

    { bpay=bp;}

  • 7/28/2019 Comp Project - Copy

    6/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah6

    void calpay()

    { double da=0.0,hra=0.0,pf=0.0,npay=0.0,gpay=0.0;da=.25*bpay;

    hra=.15*bpay;

    pf=.0833*bpay;

    npay=bpay+da+hra;

    gpay=npay-pf;

    System.out.println("Emp BASIC pay =" +bpay);

    System.out.println("Emp GROSS pay =" +gpay);

    }

    public void main()throws IOException{ employee oemp=new employee(10000.00);

    oemp.calpay();

    }

    }

    Vaiable naame Type use

    da double To store value

    hra double To store value

    pf double To store value

    npay double To store valuegpay double To store value

    Ques6:-program to use bubble sort to print merit list?

    // program to use bubble sort to print merit list

    import java.io.*;

    import java.lang.*;

    class prg22

    { public void q22()throws IOException

    { BufferedReader input=new BufferedReader(newInputStreamReader(System.in));

    int i=0,j=0,ar[]=new int[10],temp=0;

    String stname[]=new String[10],stemp=" ";

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    7/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah7

    { for(j=0;j

  • 7/28/2019 Comp Project - Copy

    8/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah8

    { System.out.print(+t+" ");

    d--;t+=d;

    }

    System.out.println();

    }

    }

    }

    Variable name type use

    i int To store value

    j int To store valued int To store value

    t int To store value

    Function

    Recursive function

    Ques8:-pogram to use recursive function to print odd numbers

    // pogram to use recursive function to print odd numbers

    import java.io.*;

    import java.lang.*;

    class rec1

    { public static void main()

    { rec1 ob1=new rec1();

    System.out.println("Printing of even numbers");

    ob1.rfodd(2);

    }

    void rfodd(int n) // defining of recursive function

    { if(n

  • 7/28/2019 Comp Project - Copy

    9/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah9

    Ques9:-Program to use recursive function to print factorial of a numbers?

    import java.io.*;import java.lang.*;

    class rec2

    { public static void main()throws IOException

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

    int num=0,i=0,f=0;

    rec2 ob2=new rec2();

    System.out.println("Enter number =");

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

    for(i=1;i

  • 7/28/2019 Comp Project - Copy

    10/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah10

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    11/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah11

    char ch=s.charAt(0);

    if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')return (1+vcount(s.substring(1)));

    else

    return vcount(s.substring(1));

    }

    }

    Variable name type Use

    st String To store namef int To store number

    Ques12:-program to use recursive function to print string in reverse?

    //pogram to use recursive function to print string in reverse

    import java.io.*;

    import java.lang.*;

    class rec5

    { public static void main()throws IOException

    { BufferedReader br=new BufferedReader(new InputStreamReader(System.in));rec5 ob=new rec5();

    String st=" ";

    System.out.println("Enter string =>");

    st=br.readLine();

    System.out.println("Reverse string =>");

    ob.rev(st);

    }

    void rev(String s)

    { if(s.length()==0)return;

    char ch=s.charAt(0);

    rev(s.substring(1));

    System.out.print(ch);

    }

    }

    Variable name Type Use

    s String To store valueof name

  • 7/28/2019 Comp Project - Copy

    12/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah12

    Ques13:-program to use recurssive for binary search?

    // program to use recurssive for binary searchimport java.io.*;

    import java.lang.*;

    class rec6

    { public static void main()throws IOException

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

    rec6 ob=new rec6();

    int res=0,ar[]=new int[5],i=0,low=0,hg=4,t=0;

    for(i=0;ihigh)

    return 0;

    else

    { mid=(lower+high)/2;

    if(sr>a[mid])

    return bin(a,mid+1,high,sr);

    else if(sr

  • 7/28/2019 Comp Project - Copy

    13/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah13

    Variable name Type Use

    res int To store value

    Ar[] int To store no.

    i int For loop

    low int To store value of low no.

    hg int To store value of hig. num

    t int To store value

    Ques14:-program to use recursive method for printing of even numbers upto 10?

    class mrec5

    { public void main()

    { prne(2);

    }

    void prne(int n)

    { if(n

  • 7/28/2019 Comp Project - Copy

    14/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah14

    }

    Variable name type usen int To store value

    Ques16:-program to use recursive method for printing of natural number upto 10?

    class mrec3

    { void prn(int n)

    { if(n

  • 7/28/2019 Comp Project - Copy

    15/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah15

    double area(int s1,int s2)

    { ar=(double)s1*s2;return ar;

    }

    double area(double r)

    { ar=3.142*r*r;

    return ar;

    }

    double area(int s1,int s2,int s3)

    { r=(s1+s2+s3)/2;

    ar=Math.sqrt(r*(r-s1)*(r-s2)*(r-s3));return ar;

    }

    public void main()throws IOException

    { BufferedReader input=new BufferedReader(new

    InputStreamReader(System.in));

    area obar=new area();

    int a1,a2,a3;

    double r1,ar1;

    int op;System.out.println("1.Area of Square");

    System.out.println("2.Area of Rectangle");

    System.out.println("3.Area of Circle");

    System.out.println("4.Area of Triangle");

    System.out.println("5.Exit");

    System.out.println("Enter your option=");

    op=Integer.parseInt(input.readLine());

    switch(op)

    { case 1: // program for square

    System.out.println("Enter side for square=");

    a1=Integer.parseInt(input.readLine());

    ar1=obar.area(a1);

    System.out.println("Area of square=" +ar1);

    break;

    case 2: // program for rectangle

    System.out.println("Enter the sides for rectangle=");

    a1=Integer.parseInt(input.readLine());

    a2=Integer.parseInt(input.readLine());

  • 7/28/2019 Comp Project - Copy

    16/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah16

    ar1=obar.area(a1,a2);

    System.out.println("Area of rectangle=" +ar1);break;

    case 3: // program for circle

    System.out.println("Enter the radius of circle=");

    r1=Double.parseDouble(input.readLine());

    ar1=obar.area(r1);

    System.out.println("Area of Circle=" +ar1);

    break;

    case 4: // program for triangle

    System.out.println("Enter the first side of triangle =");a1=Integer.parseInt(input.readLine());

    System.out.println("Enter the second side of triangle

    =");

    a2=Integer.parseInt(input.readLine());

    System.out.println("Enter the third side of triangle =");

    a3=Integer.parseInt(input.readLine());

    ar1=obar.area(a1,a2,a3);

    System.out.println("Area of Triangle=" +ar1);

    break;case 5: break;

    }

    }

    }

    Varible name Type Use

    S1 int To store value

    S2 int To store value

    S3 int To store value

    r int To store valuear int To store value

    Ques18:-to find out area of square,rectangle and circle?

    // Function overloading program

    //to find out area of square,rectangle and circle

    import java.io.*;

    import java.lang.*;

    class q6

    { double area(int s1){ double ar;

  • 7/28/2019 Comp Project - Copy

    17/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah17

    ar=(double)s1*s1;

    return ar;}

    double area(int s1,int s2)

    { double ar;

    ar=(double)s1*s2;

    return ar;

    }

    double area(double s1)

    { double ar;

    ar=3.142*s1*s1;return ar;

    }

    public void main()throws IOException

    { BufferedReader input=new BufferedReader(new

    InputStreamReader(System.in));

    int a1,a2;

    double r1,ar1;

    int op;

    System.out.println("1.Area of Square");System.out.println("2.Area of Rectangle");

    System.out.println("3.Area of Circle");

    System.out.println("4.Exit");

    System.out.println("Enter your option=");

    op=Integer.parseInt(input.readLine());

    switch(op)

    { case 1: // program for square

    System.out.println("Enter side for square=");

    a1=Integer.parseInt(input.readLine());

    ar1=area(a1);

    System.out.println("Area of square=" +ar1);

    break;

    case 2: // program for rectangle

    System.out.println("Enter the sides for rectangle=");

    a1=Integer.parseInt(input.readLine());

    a2=Integer.parseInt(input.readLine());

    ar1=area(a1,a2);

    System.out.println("Area of rectangle=" +ar1);

  • 7/28/2019 Comp Project - Copy

    18/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah18

    break;

    case 3: // program for circleSystem.out.println("Enter the radius of circle=");

    r1=Double.parseDouble(input.readLine());

    ar1=area(r1);

    System.out.println("Area of Circle=" +ar1);

    break;

    case 4: break;

    }

    }

    }Variable name Type use

    S1 int To store value

    ar int To store value

    Ques19:-menu driven program using class?

    // menu driven program using class

    import java.io.*;

    class num

    { public int no;num() //const

    { no=0;

    }

    void fact(int no)

    {int f=1,i=0;

    for(i=1;i

  • 7/28/2019 Comp Project - Copy

    19/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah19

    { case 1: // for fact

    System.out.println("Enter any number=");n=Integer.parseInt(input.readLine());

    obnum.fact(n);

    break;

    case 2: // for prime

    break;

    case 3: // for perfect

    break;

    }

    }}

    Variable name type use

    no int To store value

    f int To store value

    i int For loop

    conversion

    Ques20:-program to make a function dtob() to convert decimal to binary?

    // program to make a function dtob() to convert decimal to binaryclass q10

    { void dtob(int num)

    { int r=0,b=0,c=0;

    System.out.println("Decimal number is ="+num);

    while(num>0)

    { r=num%2;

    b+=r*Math.pow(10,c);

    c++;

    num/=2;}

    System.out.println("Binary number is ="+b);

    }

    }

    Varible name type use

    r int To store value

    b int To store value

    c int To store value

    Ques21:- program to make a function btod() to convert binary to decimal?

  • 7/28/2019 Comp Project - Copy

    20/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah20

    class q11

    { void btod(int b){ int r=0,d=0,c=0;

    System.out.println("Binary number is ="+b);

    while(b>0)

    { r=b%10;

    d+=r*Math.pow(2,c);

    c++;

    b/=10;

    }

    System.out.println(" Decimal number is="+d);}

    }

    Varible name type use

    r int To store value

    b int To store value

    c int To store value

    Ques22:-program to find the hcf of three numbers?

    // program to find the hcf of three numbers

    import java.io.*;import java.lang.*;

    class q12

    { void main()throws IOException

    { BufferedReader input=new BufferedReader(new InputStreamReader(System.in));

    int a=0,b=0,c=0,p=0,i=0,h=0;

    System.out.println("Enter any three numbers=");

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

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

    c=Integer.parseInt(input.readLine());p=a*b*c;

    for(i=1;i

  • 7/28/2019 Comp Project - Copy

    21/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah21

    Variable name Type use

    a int To store value

    b int To store value

    c int To store value

    p int To store value

    i int For loop

    Ques23:-program to find out the angle?

    import java.io.*;

    import java.lang.*;

    class q13

    { void main()throws IOException

    { BufferedReader input=new BufferedReader(new InputStreamReader(System.in));

    int a=0,b=0,c=0,p=0,i=0,h=0;

    System.out.println("Enter any measurement =");

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

    if(a

  • 7/28/2019 Comp Project - Copy

    22/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah22

    Ques24:-program to merge two array into third array?

    import java.io.*;import java.lang.*;

    class prg27

    { public void q27()throws IOException

    { BufferedReader input=new BufferedReader(new InputStreamReader(System.in));

    int i=0,j=0,ar[]=new int[4],br[]=new int[6],cr[]=new int[10],c=0;

    System.out.println("\n Enter elements for first array");

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    23/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah23

    { if(cr[i]!=cr[j])

    c++;if((cr[i]==cr[j]) && (i>j))

    break;

    }

    if(c==9)

    System.out.print(+cr[i]+" ");

    }

    System.out.println("\n\n All duplicates elements");

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    24/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah24

    else

    { if(ho

  • 7/28/2019 Comp Project - Copy

    25/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah25

    System.out.println("Enter any string=");

    st=input.readLine();pallin(st);

    }

    }

    Variable name type use

    i int To store value

    len int To store value

    pos int To store value

    c int To store value

    ch char To store value

    Ques:-program to print TOTAL VOWELS?

    // program to print TOTAL VOWELS

    class st14

    { public void q14(String st)

    { int len=0,i=0,v=0;

    char ch;

    System.out.println("Original string ="+st);

    len=st.length();

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    26/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah26

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    27/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah27

    ch=' ';

    }void dr()

    { System.out.println();

    for(i=1;i

  • 7/28/2019 Comp Project - Copy

    28/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah28

    n=Integer.parseInt(input.readLine());

    System.out.println("\nEnter character=");dh=(char)(input.read());

    d1.dr(dh,n);

    break;

    case 3: // char in rec form

    System.out.println("\nEnter a row number=");

    r=Integer.parseInt(input.readLine());

    System.out.println("\nEnter a col number=");

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

    System.out.println("\nEnter character=");dh=(char)input.read();

    d1.dr(dh,r,c);

    break;

    }

    }

    }

    Variable name type use

    a int To store value

    b int To store valuei int To store value

    j int To store value

    ch char To store value

    Ques29:-PROGRAM TO PRINT INITIAL OF A NAME

    // PROGRAM TO PRINT INITIAL OF A NAME

    class St2

    { public void q2()

    { String sen="MOHANDAS KARAMCHAND GANDHI";

    char ch;int len=0,i=0,p=0;

    len=sen.length();

    System.out.println("\nThe Name is =" +sen+"\n");

    System.out.print("The Required Initial of the name =");

    System.out.print(sen.charAt(0));

    for(i=1;i

  • 7/28/2019 Comp Project - Copy

    29/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah29

    }

    if(i==(len-1))System.out.print(sen.substring(p,len));

    }

    }

    }

    Ques:-program to input country and capital to search for a capital?

    import java.io.*;

    import java.lang.*;

    class St7

    { public void Q7()throws IOException{ BufferedReader input=new BufferedReader(new

    InputStreamReader(System.in));String wd="India";

    String co[]=new String[5], cp[]=new String[5], sco;

    int i=0,c=0;

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    30/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah30

    InheritanceQues30:-program to use inheritance?

    // program to use inheritance

    import java.io.*;

    import java.lang.*;

    class emp

    { private String name;

    double bpay;

    emp(String na,double bp)

    { this.name=na;this.bpay=bp;

    }

    void display()

    { System.out.println("Name of Employee " +name);

    System.out.println("Basic pay of Employee "+bpay);

    }

    }

    class tax extends emp

    { public int rate,hr;double tot;

    tax(String na, double bp,int rt,int h)

    { super(na,bp);

    this.rate=rt;

    this.hr=h;

    }

    void cal()

    { tot=bpay +rate *hr;

    super.display();

    System.out.println("Total rate per hour ="+rate);

    System.out.println("Total hour of working ="+hr);

    System.out.println("Total pay of employee ="+tot);

    }

    public static void main()throws IOException

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

    String n;

    double bap;

    int hour,ra;

  • 7/28/2019 Comp Project - Copy

    31/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah31

    System.out.println("Enter name , basic pay , total rate per hour and total number

    of hours =");n=br.readLine();

    bap=Double.parseDouble(br.readLine());

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

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

    tax obj=new tax(n,bap,ra,hour);

    obj.cal();

    }

    }

    Variable name Type Usename string To store value

    bpay int To store value

    Ques31:-program to use inheritance?

    package jpro;

    // program to use inheritance

    import java.io.*;

    import java.lang.*;

    class emp{ private String name;

    double bpay;

    emp(String na,double bp)

    { this.name=na;

    this.bpay=bp;

    }

    void display()

    { System.out.println("Name of Employee " +name);

    System.out.println("Basic pay of Employee "+bpay);}

    }

    class tax extends emp

    { public int rate,hr, bp;

    double tot;

    tax(String na, double bp,int rt,int h)

    { super(na,bp);

    this.rate=rt;

    this.hr=h;

    }

  • 7/28/2019 Comp Project - Copy

    32/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah32

    void cal()

    { tot=bp +rate *hr;System.out.println("Total pay of employee ="+tot);

    }

    public static void main()

    { tax obj=new tax("Amit",5000,200,20);

    obj.cal();

    }

    }

    Variable name Type Use

    name string To store valuebpay int To store value

    Ques32:-prg to show inheritance between two classes EMP AND INHEMP?

    // prg to show inheritance between two classes EMP AND INHEMP

    import java.io.*;

    import java.lang.*;

    class emp

    { private int ecode;String ename;

    double esal;

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

    emp()

    { ecode=0;

    ename=" ";

    esal=0.0;

    }

    void indata()throws IOException{ System.out.println("\n Enter Employee Code =");

    ecode=Integer.parseInt(input.readLine());

    System.out.println("\n Enter Employee Name =");

    ename=input.readLine();

    System.out.println("\n Enter Employee Basic Salary =");

    esal=Double.parseDouble(input.readLine());

    }

    void disdata()

    { System.out.println("\n\t\tEmployee Details");

    System.out.println("\n Employee Code =" +ecode);

  • 7/28/2019 Comp Project - Copy

    33/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah33

    System.out.println("\n Employee Name =" +ename);

    System.out.println("\n Employee Basic Salary =" +esal);}

    }

    class inhemp extends emp

    { public double da,hra,npay;

    inhemp()

    { da=0.0;

    hra=0.0;

    npay=0.0;

    }void in()throws IOException

    { indata();

    }

    void cal()

    { da=.57*esal;

    hra=.12*esal;

    npay=esal+da+hra;

    }

    void dis(){ disdata();

    System.out.println("\n Employee D.A =" +da);

    System.out.println("\n Employee H.R.A =" +hra);

    System.out.println("\n Employee Netpay =" +npay);

    }

    public void main()throws IOException

    { inhemp obemp=new inhemp();

    obemp.in();

    obemp.cal();

    obemp.dis();

    }

    }

    Variable name Type use

    Ename string To store value

    ecode int To store value

  • 7/28/2019 Comp Project - Copy

    34/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah34

    Ques33:-program to use selection sort to print in descending?

    import java.io.*;class q19

    { public void main()throws IOException

    { BufferedReader input=new BufferedReader(new

    InputStreamReader(System.in));

    int num[]=new int[5],i=0,j=0,tm=0,sl=0;

    //input loop

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    35/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah35

    Ques34:-program to use bubble sort to print merit list?

    // program to use bubble sort to print merit listimport java.io.*;

    class q18

    { public void main()throws IOException

    { BufferedReader input=new BufferedReader(new

    InputStreamReader(System.in));

    int num[]=new int[5],i=0,j=0,tm=0;

    String name[]=new String[10],st=" ";

    //input loop

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    36/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah36

    j int To store value

    tm int To store value

    name string To store value

    st string To store value

    Ques35:-program to search by binary search?

    // program to search by binary search

    import java.io.*;

    import java.lang.*;

    class prg26

    { public void q26() throws IOException

    { BufferedReader input=new BufferedReader(new InputStreamReader(System.in));

    int num[]=new int[10],i=0,j=0,t=0,n=0,p=0,m=0,f=0,l=9;

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    37/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah37

    else

    l=m-1;}

    if(p==0)

    System.out.println("\n search unsuccessful");

    else

    { System.out.println("\n search successful");

    System.out.println("\n Element found in "+p+ " position");

    }

    }

    }Variable name type use

    num[]; int To store value

    t int To store value

    n int To store value

    p int To store value

    m int To store value

    f int To store value

    l int To store value

    Ques36:-program to sort the string alphabetically?

    // program to sort the string alphabetically

    import java.io.*;

    import java.lang.*;

    class St9

    { public void Q9() throws IOException

    { BufferedReader input=new BufferedReader(new InputStreamReader(System.in));

    String st=" ";

    int i=0,j=0,len=0;

    System.out.println("Enter any name without space=");

    st=input.readLine();

    len=st.length();

    int a[]=new int[len],te;

    char c[]=new char[len],t=' ';

    System.out.println("Original name is given below");

    System.out.println(st);

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    38/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah38

    }

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    39/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah39

    System.out.println(st);

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    40/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah40

    };

    System.out.println("\n Binary no =" +bn);}

    }

    Variable name type use

    r int To store value

    p int To store value

    bn int To store value

    Ques39:-program to find hcf?

    class prg18

    { public void q18(int a,int b)

    { int r=0;

    System.out.println("\n Number are =" +a +" and " + b);

    r=a%b;

    while(r>0)

    { a=b;

    b=r;

    r=a%b;};

    System.out.println("\n h.c.f=" +b);

    }

    }

    Variable name type use

    a int To store value

    b int To store value

    r int To store value

    Ques40:-program to use selection sort to print in descending?

    // program to use selection sort to print in descending

    import java.io.*;

    class q19

    { public void main()throws IOException

    { BufferedReader input=new BufferedReader(new

    InputStreamReader(System.in));

    int num[]=new int[5],i=0,j=0,tm=0,sl=0;

    //input loopfor(i=0;i

  • 7/28/2019 Comp Project - Copy

    41/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah41

    { System.out.println("\n Enter the value=");

    num[i]=Integer.parseInt(input.readLine());}

    // sorting loop

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    42/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah42

    else

    o++;}

    System.out.println("\n Total even no=" +e);

    System.out.println("\n Total odd no=" +o);

    }

    }

    Variable name type use

    n int To store value

    i int To store value

    o int To store value

    e int To store value

    Ques42:- program to find sum of -ve & sum of +ve odd no , even no?

    // program to find sum of -ve & sum of +ve odd no , even no

    import java.io.*;

    import java.lang.*;

    class prg16

    {public void q16(int t)throws IOException

    {BufferedReader input=new BufferedReader(new InputStreamReader(System.in));

    int n=0,i=0,sng=0,po=0,pe=0;

    for(i=1;i

  • 7/28/2019 Comp Project - Copy

    43/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah43

    System.out.println("\n Total sum of odd no=" +po);

    System.out.println("\n Total sum of even no=" +pe);}

    }

    Variable name type use

    n int To store value

    i int To store value

    sng int To store value

    po int To store value

    pe int To store value

    Ques43:-program to check s number to be perfect or not?

    // program to check s number to be perfect or not

    class prg17

    { public void q17(int n)

    { int i=0,r=0,s=0;

    for(i=1;i

  • 7/28/2019 Comp Project - Copy

    44/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah44

    { for(j=1;j

  • 7/28/2019 Comp Project - Copy

    45/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah45

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

    System.out.println("Enter second value =");b=Integer.parseInt(input.readLine());

    System.out.println("\n Difference of two Numbers =" +(a-b));

    break;

    case 3: break;

    default:System.out.println("\n Sorry wrong option");

    break;

    }

    }

    }Variable name type use

    a int To store value

    b int To store value

    op int To store value

    Ques46:-program to use bubble sort to print merit list?

    // program to use bubble sort to print merit list

    import java.io.*;

    class q18{ public void main()throws IOException

    { BufferedReader input=new BufferedReader(new

    InputStreamReader(System.in));

    int num[]=new int[5],i=0,j=0,tm=0;

    String name[]=new String[10],st=" ";

    //input loop

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    46/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah46

    num[i]=num[j];

    name[j]=st;num[j]=tm;

    }

    }

    }

    System.out.println("\t\tMerit list");

    System.out.println("S.No\t\tStudent Name \t\tMarks");

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    47/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah47

    System.out.println("\n temp in Cel =" +c);

    break;case 2: // program cel to fre

    System.out.println("Enter temp in cel =");

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

    f=(9*c)/5 +32;

    System.out.println("\n Temp in fre =" +f);

    break;

    case 3: break;

    default:System.out.println("\n Sorry wrong option");

    break;}

    }

    }

    Variable name type Use

    f int To store value

    c int To store value

    op int To store valueof chioce

    Ques48:-program to use linear search?

    // program to use linear search

    import java.io.*;

    class q17

    { public void main()throws IOException

    { BufferedReader input=new BufferedReader(new

    InputStreamReader(System.in));

    int i=0,c=0;double tn[]=new double[5],stn;

    String cn[]=new String[5];

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    48/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah48

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    49/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah49

    r=a%b;

    while(r>0){ a=b;

    b=r;

    r=a%b;

    };

    System.out.println("\n lcm of two Numbers =" +p/b);

    break;

    case 2: // program on hcf

    System.out.println("Enter first value =");

    a=Integer.parseInt(input.readLine());System.out.println("Enter second value =");

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

    r=a%b;

    while(r>0)

    { a=b;

    b=r;

    r=a%b;

    };

    System.out.println("\n hcf of two Numbers =" +b);break;

    case 3: break;

    default:

    System.out.println("\n Sorry wrong option");

    break;

    }

    }

    }

    Variable name Type Use

    a int To store value

    b int To store value

    p int To store value

    r int To store value

    op int To store value

  • 7/28/2019 Comp Project - Copy

    50/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah50

    Ques50:- program to store 10 values to find out mean and fre dis table?

    // program to store 10 values to find out mean and fre dis tableimport java.io.*;

    class q16

    { public void main()throws IOException

    { BufferedReader input=new BufferedReader(new

    InputStreamReader(System.in));

    int i=0,num[]=new int[10],a=0,b=0,c=0,d=0;

    double sum=0.0,mean=0.0;

    System.out.println("Enter the ten values ");

    for(i=0;i80)

    a++;

    else if(num[i]>60)

    b++;

    else if(num[i]>40)

    c++;

    else

    d++;sum+=num[i];

    }

    mean=sum/10;

    System.out.println("\t\tFrequency Distribution Table");

    System.out.println("Class Interval\t\tFrequency");

    System.out.println("81-100\t\t\t\t" +a);

    System.out.println("61-80\t\t\t\t" +b);

    System.out.println("41-60\t\t\t\t" +c);

    System.out.println("below =40\t\t\t" +d);

    System.out.println("Mean of the ten numbers ="+mean);

    }

    }

    Variable name type use

    i int To store value

    d int To store value

    sum int To store value

    mean int To store value

    a int To store valueb int To store value

  • 7/28/2019 Comp Project - Copy

    51/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah51

    Ques51:-program to use menu driven on mathematical operation?

    //program to use menu driven on mathematical operation// using loop do-while

    import java.io.*;

    import java.lang.*;

    class prg12

    { public void q12()throws IOException

    { BufferedReader input=new BufferedReader(new InputStreamReader(System.in));

    int op=0;

    int a=0,b=0;

    System.out.println("\n\t\t\t Main Menu");System.out.println("\n\t 1. Addition");

    System.out.println("\n\t 2. Subtraction");

    System.out.println("\n\t 3. Exit");

    System.out.println("\n\t Enter your option ( 1-3)=");

    op= Integer.parseInt(input.readLine());

    switch(op)

    { case 1: // program to add

    System.out.println("Enter first value =");

    a=Integer.parseInt(input.readLine());System.out.println("Enter second value =");

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

    System.out.println("\n Sum of two Numbers =" +(a+b));

    break;

    case 2: // program to subtract

    System.out.println("Enter first value =");

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

    System.out.println("Enter second value =");

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

    System.out.println("\n Difference of two Numbers =" +(a-b));

    break;

    case 3: break;

    default:System.out.println("Sorry wrong option ");

    break;

    }

    }

    }

  • 7/28/2019 Comp Project - Copy

    52/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah52

    Variable name type use

    a int To store number

    b int To store number

    op int To store number

    Ques52:- loop in desending order?

    class q14

    { public void main()

    { int i=0,j=0;

    for(i=4;i>=1;i--)

    { for(j=i;j>=1;j--)

    System.out.print(j+" ");

    System.out.println();

    }

    }

    }

    Variable name type use

    i int For loop

    j int For loop

    Ques53:- program to use nested if to find out fine?

    // program to use nested if to find out fine

    class prg10

    { public void q10(int n)

    { double fn;

    if(n

  • 7/28/2019 Comp Project - Copy

    53/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah53

    Ques54:- program to return statement?

    // program to return statementimport java.io.*;

    import java.lang.*;

    class work

    { public int a,b;

    double c;

    work()

    { a=0;

    b=0;

    c=0.0;}

    double add(int a,int b)

    { c=(double)a+b;

    return c;

    }

    }

    class prg25

    { public void q25()throws IOException

    { work obwork=new work();BufferedReader input=new BufferedReader(new

    InputStreamReader(System.in));

    int x=0,y=0;

    double sum=0.0;

    System.out.println("Enter first value =");

    x=Integer.parseInt(input.readLine());

    System.out.println("Enter second value =");

    y=Integer.parseInt(input.readLine());

    sum=obwork.add(x,y);

    System.out.println("Sum of two numbers =" +sum);

    }

    }

    VARIABLE NAME TYPE USE

    a int To accept a

    numberfor method

    b Int To accept a number

    for method

    c double To add numberQues55:- to find highest,middle and lowest?

  • 7/28/2019 Comp Project - Copy

    54/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah54

    //to find highest,middle and lowest

    class pr11{ public void q11(int a,int b,int c)

    {

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

    { System.out.println("The Highest number is="+a);

    if(b>c)

    { System.out.println("The middle number is="+b);

    System.out.println("The lowest number is="+c);

    }

    else{ System.out.println("The middle number is="+c);

    System.out.println("The lowest number is="+b);

    }

    }

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

    { System.out.println("The Highest number is="+b);

    if(c>a)

    { System.out.println("The middle number is="+c);

    System.out.println("The lowest number is="+a);}

    else

    { System.out.println("The middle number is="+a);

    System.out.println("The lowest number is="+c);

    }

    }

    else

    { System.out.println("The Highest numberis="+c);

    if(a>b)

    { System.out.println("The middle number is="+a);

    System.out.println("The lowest number is="+b);

    }

    else

    { System.out.println("The middle number is="+b);

    System.out.println("The lowest number is="+a);

    }

    }

    }

  • 7/28/2019 Comp Project - Copy

    55/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah55

    }

    Variable name Type Usesa int To store number

    b int To store number

    c int To store number

    Ques56:- program to check smith number?

    // program to check smith number

    import java.io.*;

    import java.lang.*;

    class csmith

    { public int num,temp,s,sum;

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

    void input()throws IOException

    { System.out.println("Enter any decimal number =");

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

    }

    int sdigit(int n)

    { s=0;

    while(n>0){ s+=n%10;

    n/=10;

    }

    return s;

    }

    void pfact()throws IOException

    { input();

    temp=num;

    int f=0,c=2,i=0;sum=0;

    while(num>1)

    { if(num%c==0)

    { f=0;

    for(i=1;i

  • 7/28/2019 Comp Project - Copy

    56/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah56

    num/=c;

    }else

    c++;

    }

    if(sum==sdigit(temp))

    System.out.println("Number is Smith number");

    else

    System.out.println("number is not Smith number");

    }

    public static void main()throws IOException{ csmith obj=new csmith();

    obj.pfact();

    }

    }

    Variable name Type Uses

    num int To store number

    temp int To store value of num

    s int To store value of remainder

    sum int To store sum

    Ques57:-pogram to create a class to check palindrome?

    // pogram to create a class to check pallindrome

    import java.io.*;

    import java.lang.*;

    class pallin

    { public String st[]=new String[5], rev[]=new String[5];

    int i,j,c,len[]=new int[5];

    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));void input()throws IOException

    { for(i=0;i

  • 7/28/2019 Comp Project - Copy

    57/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah57

    for(j=len[i]-1;j>=0;j--)

    { char ch=st[i].charAt(j);rev[i]+=ch;

    }

    }

    }

    void check()

    { for(i=0;i

  • 7/28/2019 Comp Project - Copy

    58/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah58

    int s=0,c=0,len=0,i=0,j=0,l[]=new int[20],t=0;

    System.out.println("Enter the sentence =");st=input.readLine();

    len=st.length();

    // for each word

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    59/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah59

    Varible name Type Use

    st String To store value

    fst String To store value

    Arrst[] String To store value

    i int For loop

    c int For counter

    len int To store length

    t int For counter

    Ques59:- program to search for a name in the list also display the phno?

    // program to search for a name in the list also display the phno

    import java.io.*;

    import java.lang.*;

    class St24

    { public void Q16()throws IOException

    { BufferedReader input=new BufferedReader(new

    InputStreamReader(System.in));String wd="India";

    String st[]=new String[5],temp;

    long ph[]=new long[5];

    int i=0,c=0,sr=0;

    for(i=0;i

  • 7/28/2019 Comp Project - Copy

    60/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah60

    else

    System.out.println("Search not successful");}

    }

    Variable name type Use

    i int For loop

    j int For loop

    sr int To store value

    c int To store value

    wd string To store value

    S[] string To store valueof names

    Ques60:-program to arrange all number by sorting?

    import java.io.*;

    import java.lang.*;

    class arrange

    { public int num[]=new int[100],temp,i,j,pos,n;

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

    void input()throws IOException

    { for(i=0;i

  • 7/28/2019 Comp Project - Copy

    61/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    Submitted to:- sanjay kumar shah61

    { for(i=0;i

  • 7/28/2019 Comp Project - Copy

    62/62

    Computer Project On java Programming

    Name Divya Jyoti

    Class- XIIth A

    break;

    case 2: obj.input();obj.ssort();

    break;

    case 3: obj.input();

    obj.exsort();

    break;

    }

    }

    }

    Variable name Type Usenum[] int To store number

    temp int To store number

    i int Foor loop

    j int For loop

    pos int To store number

    n int To store number